scoped 1.9.0 copy "scoped: ^1.9.0" to clipboard
scoped: ^1.9.0 copied to clipboard

outdated

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 locator
  • Scope - an inherited widget to help getting access to your store
  • Fluid - a simple Listenable implementation for your models

I hope you enjoy it.

Example

pubspec.yaml

dependencies:
  scoped: ^1.9.0

lib\main.dart

import 'package:scoped/scoped.dart';
import 'package:scoped/material.dart';

class Service {
  final Ref<String> foo = Ref();

  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))
      ]
    );
  }
}
6
likes
0
pub points
10%
popularity

Publisher

verified publisherswipelab.co

a pragmatic state management solution. comes with instance store (single, lazy & and scoped) and handy connectors

Repository
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on scoped