Skip to content
pubscout

scoped_model

2.0.0, released 4 years ago by an unverified publisher

Pass a reactive data model down the widget tree and rebuild descendants when it updates.

WASM-ready
$ flutter pub add scoped_model
Source repository

What it does

Provides a Model class and ScopedModel widgets that allow developers to pass state down the widget tree. Descendant widgets automatically rebuild when the model notifies listeners of changes.

AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want simple state management without complex boilerplate
  • You need to pass models down to specific descendants and rebuild them on changes

Skip it when

  • You are building a massive application that requires a robust scalable architecture
  • You prefer modern state management solutions with built-in dependency injection

Strengths

  • Very simple and lightweight
  • Easy to learn and understand for basic state management
  • Built on standard Flutter InheritedWidgets

Weaknesses

  • Lacks advanced state management patterns
  • Can lead to deeply nested ScopedModel widgets in large apps

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0

not documented

class CounterModel extends Model {
  int _counter = 0;
  int get counter => _counter;
  void increment() {
    _counter++;
    notifyListeners();
  }
}

class CounterApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ScopedModel<CounterModel>(
      model: CounterModel(),
      child: ScopedModelDescendant<CounterModel>(
        builder: (context, child, model) => Text('${model.counter}'),
      ),
    );
  }
}

Alternatives

Packages that do the same job and could replace scoped_model.