パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.1.5

dartin

Flutter開発者向けの実用的で軽量な依存関係注入フレームワーク。

30日間ダウンロード
100
いいね数
8
Pub ポイント
40

パッケージをインストール

flutter pub add dartin

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Dartinは、Flutter開発者向けに設計された軽量で実用的な依存関係注入フレームワークです。シンプルで効率的な方法で依存関係を登録・解決できるため、Flutterアプリケーションにおける依存関係の管理を簡素化します。最小限のボイラープレートと直感的な構文により、既存プロジェクトへの統合が容易で、複雑さを加えることなく利用できます。単純なユースケースから高度なユースケースまで対応しており、小さなプロトタイプから大規模アプリケーションまで幅広く活用可能です。開発者の体験とパフォーマンスを重視し、高速な起動時間と信頼性の高い依存関係解決を実現しています。

用途

  • シンプルなアプリケーションの依存関係管理
  • 大規模なFlutterアプリケーションアーキテクチャ
  • モックされた依存関係を使用したテスト
  • 迅速なプロトタイピング
  • モジュール型アプリ開発
  • 状態管理の統合

主な機能

  • 最小限のボイラープレート
  • 簡単なセットアップと構成
  • シングルトンおよび一時インスタンスをサポート
  • テストの組み込みサポート
  • 軽量なフットプリント
  • 直感的な API デザイン

適している対象

  • シンプルなDIを求めるFlutter初心者
  • 軽量なDIが必要な経験豊富な開発者
  • モジュール式Flutterアプリを開発するチーム
  • テスト可能な依存関係構造を必要とするプロジェクト
  • 進化する依存関係のニーズを持つアプリ

注意事項

  • 大きなフレームワークと比べてドキュメントが限られている
  • 組み込みの状態管理なし
  • 非常に複雑な依存関係グラフには適していません
  • コミュニティの規模は他の代替案よりも小さい
  • 高度な機能には手動設定が必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

dartin

A pragmatic lightweight dependency injection framework for Flutter developers.

A light container inspired by flutter-provide and koin.

more examples see mvvm_flutter.

Setup
dependencies:
  dartin: ^0.1.5
  
Key methods
  • single:Creates a provider which will initialize using the [_DartInFunction] the first time the value is requested.

  • factory:Creates a provider that provides a new value using the [_DartInFunction] for each requestor of the value.

  • inject:get T from dartIns by T.runtimeType and params

more informations see dartin.dart.

Getting Started
  1. declare dartin modules
//scope should always be initialized as a static const and passed around.
const test = DartInScope('test');

final viewModelModule = Module([
  factory<HomeProvide>(({params}) => HomeProvide(params.get(0), get<GithubRepo>())),
])
  ..withScope(test , [
    ///other scope
   factory<HomeProvide>(({params}) => HomeProvide(params.get(0), get<GithubRepo>())),
  ]);

final repoModule = Module([
  single<GithubRepo>(({params}) => GithubRepo(get<GithubService>())),
]);

final remoteModule = Module([
  single<GithubService>(({params}) => GithubService()),
]);

final appModule = [viewModelModule, repoModule, remoteModule];

  1. Start dartin
void main() {
  startDartIn(appModule);
  runApp(MyApp());
}
  1. inject
//default
final service = inject<GithubService>();
//pass parameters
final test = inject<HomeProvide>(params: ['title']);
//different scope
final test = inject<HomeProvide>(scope:test,params: ['title']);

DartIn is easy to use, and still improving.

🍺 welcome to fork and pull request。

Article

【Medium】:DartIn:A pragmatic lightweight dependency injection framework for Flutter developers

【简书】:为Flutter而生的轻量级依赖检索容器—DartIn

【掘金】:为Flutter而生的轻量级依赖检索容器—DartIn

Licence

BSD

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト