Created
March 5, 2021 09:04
-
-
Save daixianceng/24e3a5d0d4bd8b908080cf763122a89c to your computer and use it in GitHub Desktop.
flutter redux store example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class Store extends ChangeNotifier { | |
static Store singleton = Store(); | |
Map<dynamic, dynamic> _state = {}; | |
Map<dynamic, dynamic> get state => _state; | |
void setState(Map<dynamic, dynamic> state) { | |
_state = {..._state, ...state}; | |
// This call tells the widgets that are listening to this model to rebuild. | |
notifyListeners(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: