scoped 1.0.0

scoped #

A very pragmatic way to handle your state with one goal in mind:

Simplicity

Example

pubspec.yaml

dependencies:
  scoped: ^1.0.0

lib\main.dart

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

void main() => runApp(Scope(
  store:Store()
    ..add(Service('a great service')),
  child: YourApp()));

class Service {
  final String name;
  Service(this.name);
}

class YourApp extends StatelessWidget {
  Wiget build(BuildingContext context){
    return Bond<Service>(builder: (context, service)=> Text(service.name));
  }
}

with bonds

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

void main() => runApp(Scope(
  store:Store()
    ..add(Service('a great service')),
  child: YourApp()));

class Service extends Fluid {
  String _name;
  String name;
  set name(String value){
    _name = value;
    notify();
  }
  Service(String name):_name=name;
}

class YourApp extends StatelessWidget {
  Wiget build(BuildingContext context){
    return Column(
      children: [
        Bond<Service>(
          builder: (context, service) => Text(service.name)),
        FlatButton(
          child:Text("Change"),
          onPressed:() => Scope.get<Service>(context).name = 'changed')
      ]);
  }
}

with fluid models

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

void main() => runApp(Scope(
  store:Store()
    ..add(Service('a great service')),
  child: YourApp()));

class Service extends Fluid {
  String _name;
  String name;
  set name(String value){
    _name = value;
    notify();
  }
  Service(String name):_name=name;
}

class YourApp extends StatelessWidget {
  Wiget build(BuildingContext context){
    return Column(
      children: [
        FluidBuilder<Service>(
          fluid: Scope.get<Service>(context),
          builder: (context, s) => Text(s.name)),
        FlatButton(
          child:Text("Change"),
          onPressed:() => Scope.get<Service>(context).name = 'changed')
      ]);
  }
}

[1.0.0]

added bond allows fluid to be mixed in with your models

[0.4.0]

added fluids

[0.3.0]

exposed access store in Scoped

[0.2.0]

added fluid

[0.1.0]

ready to use

[0.0.1]

initial release.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  scoped: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:scoped/scoped.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
63
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

We analyzed this package on Feb 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Fix lib/src/scope.dart. (-0.50 points)

Analysis of lib/src/scope.dart reported 1 hint:

line 14 col 15: 'inheritFromWidgetOfExactType' is deprecated and shouldn't be used. Use dependOnInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Format lib/scoped.dart.

Run flutter format to format lib/scoped.dart.

Format lib/src/binder.dart.

Run flutter format to format lib/src/binder.dart.

Format lib/src/fluid.dart.

Run flutter format to format lib/src/fluid.dart.

Format lib/src/fluids.dart.

Run flutter format to format lib/src/fluids.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and scoped.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test