lite_ref 0.0.2 copy "lite_ref: ^0.0.2" to clipboard
lite_ref: ^0.0.2 copied to clipboard

A lightweight dependency injection package.

Overview #

Lite Ref is a lightweight dependency injection library for Dart and Flutter.

Installation #

dart pub add lite_ref

Usage #

LifeRefs are lazy. They are only instantiated when you call instance or ().

import 'package:lite_ref/lite_ref.dart';

// create a singleton
var dbRef = LiteRef(() => Database());

// use it
// refs are also callable so you can replace dbRef.instace with dbRef()
var db = await dbRef.instance;

// override for testing
dbRef.overrideWith(() => MockDatabase());

// create a transient (always new instance)
var userService = LiteRef(() => UserService(database: dbRef()), cache: false);
14
likes
0
pub points
69%
popularity

Publisher

verified publishernosy.dev

A lightweight dependency injection package.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

meta

More

Packages that depend on lite_ref