scoped 3.1.1 copy "scoped: ^3.1.1" to clipboard
scoped: ^3.1.1 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 locator
  • Scope - an inherited widget to help getting access to your store
  • Reactive - a simple way to add reactivity to your models
  • Ref<T> - reactive value
  • Refs<T> - reactive 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 Refs<String> foos = Refs();

  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
150
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 (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on scoped