Flutter 全局状态管理 redux & scoped_model
flutter_redux
// One simple action: Increment enum Actions { Increment } // The reducer, which takes the previous count and increments it in response // to an Increment action. int counterReducer(int state,dynamic action){ if(action == Actions.Increment){ return state +1; } return state; } void main(){ // Create your store as a final variable in a base Widget. This works better // with Hot Reload than creating it directly in the `build` function. final store = new Store<int>(counterReducer,initialState: 0); runApp(new FlutterReduxApp( title: 'Flutter Redux App', store: store, )); } class FlutterReduxApp extends StatelessWidget { final String title; final Store<int> store; FlutterReduxApp({ Key key,this.store,this.title}):super(key:key); @override Widget build(BuildContext context) { // The StoreProvider should wrap your MaterialApp or WidgetsApp. This will // ensure all routes have access to the store. return StoreProvider<int>( store: store, child: new MaterialApp( theme: new ThemeDa