scoped 1.9.6 scoped: ^1.9.6 copied to clipboard
a pragmatic state management solution. comes with instance store (single, lazy & and scoped) and handy connectors
scoped #
A very pragmatic way to access your services and state with one goal in mind:
Simplicity
Scoped is a made up of tree main components
Store
- a simple service locatorScope
- an inherited widget to help getting access to your storeFluid
- a simpleListenable
implementation for your modelsRef<T>
- observable valueStrip<T>
- observable list
I hope you enjoy it.
Example
pubspec.yaml
dependencies:
scoped: ^2.0.0
lib\main.dart
import 'package:scoped/scoped.dart';
import 'package:scoped/material.dart';
class Service {
final Ref<String> foo = Ref();
final Strip<String> foos = Strip();
final String name;
Service(this.name);
change(){
foo.value = 'bar';
}
}
void main() => runApp(Scope(
store:Store()
..add(Service('a great service')),
child: YourApp()));
class YourApp extends StatelessWidget {
Wiget build(BuildingContext context){
return Column(
children:[
Text(context.get<Service>().name),
FlatButton(
child:Text("Change"),
onPressed:() => context.get<Service>().change(),
context.get<Service>().foo.bindValue((_,v)=> Text(v))
]
);
}
}