If you want to get data from the FutureProvider in flutter? FutureProvider exposes the result of the Future returned by builder to its descendants.
As such, using the following FutureProvider:
1 2 3 4 5 | FutureProvider<int>( initialData: 0, builder: (_) => Future.value(42), child: ... ) |
It is possible to obtain the current value through:
1 2 3 4 5 | Consumer<int>( builder: (context, value, __) { return Text(value.toString()); } ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.