StateProvider for Flutter

A lightweight StateProvider for handling global data. This Plugin wraps an InheritedWidget into a StreamBuilder for updating the UI if any changes appears in the InheritedWidget.

Getting Started

1. Import stateprovider

import 'package:stateprovider/stateprovider.dart';

2. Create a Model which extends the Store class. Add your custom attributes and functions. Call notify() in every function where you want to update the state.

class MyModel extends Store<MyModel> {

  String name = "";
  int age = 0; 

  //stores only the new data but doesn't update the ui
  void setName(String name) { = name;

  //updates the ui because of notify()
  void setAge(int age) {
    this.index = index;


3. Add the StatefulProvider widget in the SECOND position of your tree under MaterialApp or CupertinoApp. Add your custom Model to the StatefulProvider.

void main() => runApp(
    home: StatefulProvider(
      store: MyModel(),
      child: PageOne(),

4. Now inside your widget you can use your data with the StateProvider class:



if you want to update the state manually use: