stark 0.0.1 copy "stark: ^0.0.1" to clipboard
stark: ^0.0.1 copied to clipboard

outdated

Stark - a pragmatic lightweight dependency injection framework for Dart

stark #

What is Stark? #

A pragmatic lightweight dependency injection framework for Dart developers.

Some info #

This project is based on koin

This implementation does not rely on the dart reflection apis (mirrors) and favours a simple factory based approach. This increases the performance and simplicity of this implementation.

Any help is appreciated! Comment, suggestions, issues, PR's!

Getting Started #

In your flutter or dart project add the dependency:

dependencies:
  ...
  stark: 0.0.1

Usage example #

Import stark

import 'package:stark/stark.dart';

Create a Module #

import 'package:stark/stark.dart';

final appModule = {
    Single((i) => Api()), //Singleton definition
    Single((i) => Repository(i.get())), //Singleton definition with injection parameters
    Factory((i) => UseCase(i.get())) , //Factory definition
    Factory.withParams((i, p) => ViewModel(i.get(), p["dynamicParam"])), //Factory definition with dynamic params
};

Initialize Stark passing a list of modules in your initial class or Widget (for Flutter ) #

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {

    //You can pass a list with many modules
    Stark.init([appModule]);

    return MaterialApp(
      ...
    );
  }
}

Getting a inject instance #

class LoginScreen extends StatefulWidget{
  @override
  State<StatefulWidget> createState()  => LoginScreenState();
}

class LoginScreenState extends State<LoginScreen>{

  final _loginViewModel = Stark.get<LoginViewModel>();

  @override
  Widget build(BuildContext context) {
   
    return  Container(
        ...
    );
  }
}

Features and bugs #

Please send feature requests and bugs at the issue tracker.

9
likes
0
pub points
65%
popularity

Publisher

verified publishersoftarch.dev

Stark - a pragmatic lightweight dependency injection framework for Dart

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on stark