Maksim Ryzhikov
1 min readFeb 14, 2019

--

Sure,

In the article, I use “ValueNotifier” to hold the app state and notify about changes. But “ValueNotifier” restricts us to use immutable data.

So, in the case with a dictionary instead of int the code will look like this:

var appState = new AppState({"counter": 0});
...
class MyHomePage extends StatelessWidget {
Widget build(BuildContext context) {
var _counter = Provider.of(context).value["counter"];
return new Scaffold(
...
_incrementCounter(context) {
var appState = Provider.of(context);
appState.value = Map.from(appState.value)..["counter"] += 1;
}
}

--

--

No responses yet