패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.1.5

dartin

Flutter 개발자를 위한 실용적이고 가벼운 종속성 주입 프레임워크입니다.

30일 다운로드
100
좋아요
8
Pub 점수
40

패키지 설치

flutter pub add dartin

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Dartin은 Flutter 개발자를 위한 가볍고 실용적인 종속성 주입 프레임워크입니다. 간결하고 효율적인 방식으로 종속성을 등록하고 해결함으로써 Flutter 애플리케이션에서 종속성 관리를 단순화합니다. 최소한의 보일러플레이트와 직관적인 구문을 통해 기존 프로젝트에 쉽게 통합할 수 있으며 복잡성을 추가하지 않습니다. 간단한 사용 사례부터 고급 사용 사례까지 지원하여 소규모 프로토타입부터 대규모 애플리케이션까지 다양한 앱에 적합합니다. 개발자 경험과 성능을 중시하며 빠른 시작 시간과 신뢰할 수 있는 종속성 해결을 보장합니다.

사용 사례

  • 간단한 애플리케이션 종속성 관리
  • 대규모 플러터 애플리케이션 아키텍처
  • 모의 종속성으로 테스트하기
  • 빠른 프로토타이핑
  • 모듈러 앱 개발
  • 상태 관리 통합

주요 기능

  • 최소한의 보일러플레이트
  • 간편한 설정 및 구성
  • 싱글턴 및 일시적 인스턴스 지원
  • 테스트를 위한 내장 지원
  • 경량 피트프린트
  • 직관적인 API 설계

적합한 대상

  • 간단한 DI를 찾는 플러터 초보자
  • 경험 많은 개발자들이 경량 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

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트