Questions tagged [flutter-provider]

For questions relating to the "Provider" package for the Flutter framework. Use this tag in combination with the general [flutter] tag. If your question applies to Flutter more generally, use the [flutter] tag only.

This tag should be used for any questions regarding the provider package for the framework.

The provider is a wrapper around InheritedWidget to make them easier to use and more reusable.

Provider uses InheritedWidget's to provide dependency injection functionality for state management in Flutter applications.

To get started, one can read through the README on GitHub, i.e. on the official GitHub page for the provider package.

1487 questions
19
votes
6 answers

Widget cannot be marked as needing to build because the framework is already in the process of building widgets

I'm trying to implement Provider and it seems it works fine but I get this message: This _DefaultInheritedProviderScope widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget…
John Smith Optional
  • 431
  • 2
  • 4
  • 18
19
votes
3 answers

Could not find the correct Provider - Flutter

@override Widget build(BuildContext context) { return WillPopScope( onWillPop: () async { return false; }, child: Stack( children: [ DefaultTabController( length: 5, …
janosdupai
  • 519
  • 1
  • 5
  • 16
19
votes
3 answers

Provider vs. InheritedWidget

Am I wrong or if we just want to pass a value down the Widget tree, Provider is just an InheritedWidget with a dispose method?
Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
18
votes
2 answers

flutter provider changenotifierprovider question

I am looking at the following code on flutter's website: void main() { runApp( MultiProvider( providers: [ ChangeNotifierProvider(create: (context) => CartModel()), Provider(create: (context) => SomeOtherClass()), …
Matt123
  • 293
  • 1
  • 4
  • 10
18
votes
4 answers

How to pass provider with Navigator?

I need pass provider (Model2) from homepage to Page2 so when user go back to homepage (onWillPop) I can make API call from provider (Model2) and update homepage. But when I call _onPaidBackPress(context) there is error: Unhandled Exception: Error:…
FlutterFirebase
  • 2,163
  • 6
  • 28
  • 60
18
votes
1 answer

flutter provider MultiProvider using StreamProvider

I am developing a Flutter app using Provider (provider: 3.0.0+1). I am using MultiProvider using StreamProvider with controller. But I am always getting an error. Below is my code main.dart Widget build(BuildContext context) { return MultiProvider( …
user280960
  • 711
  • 15
  • 30
17
votes
4 answers

Setting provider value in FutureBuilder

I have a widget that makes a request to an api which returns a map. What I would like to do is not make the same request every time the widget is loaded and save the list to appState.myList. But. when I do this appState.myList = snapshot.data; in…
Ciprian
  • 3,066
  • 9
  • 62
  • 98
17
votes
3 answers

Error: Could not find the correct Provider above this widget

This screen is a Drawer screen which take the auth bloc in order to provide user the info and enable him of logout. I got this error although I am using the correct provider The following ProviderNotFoundError was thrown building…
Aya Elsisy
  • 2,029
  • 4
  • 13
  • 23
16
votes
2 answers

How to show errors from ChangeNotifier using Provider in Flutter

I'm trying to find the best way to show errors from a Change Notifier Model with Provider through a Snackbar. Is there any built-in way or any advice you could help me with? I found this way that is working but I don't know if it's correct. Suppose…
16
votes
1 answer

How to consume Provider after navigating to another route?

My app have 2 type of user: admin and normal. I show admin screen to admin and normal screen to normal user. All user need access Provider model1. But only admin need access model2. How I can initialise only model2 for admin user? For…
FlutterFirebase
  • 2,163
  • 6
  • 28
  • 60
15
votes
1 answer

Flutter - Looking up a deactivated widget's ancestor is unsafe with Provider package, FireStore authentication

I have an problem with showing message via SnackBar using Provider package. The error message I get is: VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe. At this point the state of the…
Sam
  • 308
  • 1
  • 3
  • 14
15
votes
4 answers

Flutter: how to play animation with Provider?

I use Provider to manage state in my Flutter demo. I want to animate my widget but it seems that AnimateController needs a sync parameter that comes from the state of a stateful widget. As far as I know, Provider is not recommended to use with a…
FAN
  • 189
  • 1
  • 7
14
votes
3 answers

Is Provider.of(context, listen: false) equivalent to context.read()?

// Are these the same? final model = Provider.of(context, listen: false); final model = context.read(); // Are these the same? final model = Provider.of(context); final model = context.watch(); Are they the same or…
iDecode
  • 22,623
  • 19
  • 99
  • 186
14
votes
2 answers

How to use textEditiing controller with Provider in Flutter

I am using provider for state management. I am in a situation where there are multiple types of fields in my form. The problem is with text-field Whenever I change Text it is behaving weirdly like the text entered is displayed in reverse…
vinayak bhanushali
  • 213
  • 1
  • 3
  • 9
14
votes
2 answers

how to add multiple ChangeNotifierProvider in same type in Flutter

Is it possible to add same type multiple ChangeNotifierProvider? return MultiProvider( providers: [ ChangeNotifierProvider>( create: (_) => ValueNotifier(0.0), ), …
BIS Tech
  • 17,000
  • 12
  • 99
  • 148