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
0
votes
1 answer

length was null using Provider

App is working smoothly. But Error is showing on the console. The getter 'length' was called on null. Receiver: null Tried calling: length User-created ancestor of the error-causing widget was: StreamProvider> …
BIS Tech
  • 17,000
  • 12
  • 99
  • 148
0
votes
2 answers

Provider not accesable when Navigate to new screen

have a problem that I'm sitting on couple of days now. have an app where: depending of AUTH state, 'LoginScreen' or 'MainScreen' is Shown. in MainScreen I setUp bottomNavigation with screens (HomeScreen, ShoppingScreen,MyFavorites) I set up there…
pb4now
  • 1,305
  • 4
  • 18
  • 45
0
votes
0 answers

How to mix stream with Provider?

I am use Provider. I want mix different data source with stream. Use case: Chat app where some message are from system (date/error message) but other are from database (Firestore). For example for just get message from database I now use…
FlutterFirebase
  • 2,163
  • 6
  • 28
  • 60
0
votes
0 answers

Flutter FutureProvider is not updating child after the future completes

I am using the Provider Package. I am using the FutureProvider to load a json file. The FutureProvider also has a ChangeNotifierProvider as a child. I am not sure what is going awry when I do this but my child is not being rebuilt. The bottom sheet…
0
votes
1 answer

Using Flutter Provider package Selector widget rebuilds unnecessary widgets

When I update a ChangeNotifier class instance variable using Provider.of(context, listen: true).value all Selector widgets dependent on that class are rebuilt (as if I used a Consumer rather than a Selector widget). If I update an instance…
Tony T
  • 1
  • 2
0
votes
0 answers

Choosing the right strategy with dependencies when using Provider/ProxyProvider

I am trying to set all dependencies using Provider and not using get_it or other kind of instantiation in initState return MultiProvider( providers: [ Provider.value(value: FbUserRepository()), …
cosinus
  • 1,905
  • 3
  • 15
  • 21
0
votes
1 answer

Streambuilder returning null inside consumer

I am trying to pull data from firestore using streambuilder which is wrapped in a consumer like below. However, for some reason it is returning a null error. I am confused why this is returning an error when I use consumer but works fine without…
0
votes
1 answer

Error: "Expected a method, getter, setter or operator declaration"

I am getting the error: "Expected a method, getter, setter or operator declaration" when I am implementing the below code. It includes a provider, consumer and StreamBuilder. Is there something I am doing wrong with the below implementation? I have…
James Roth
  • 81
  • 1
  • 2
  • 12
0
votes
1 answer

Implementing provider

I am trying to implement provider at the top of my app, but am getting an error: "positional arguments: 0 expected, but 1 found". I have tried different implementations but then I get runtime error "build function returned null". Is there something…
James Roth
  • 81
  • 1
  • 2
  • 12
0
votes
1 answer

Error when using StreamProvider and StreamBuilder

I am trying to use StreamProvider and StreamBuilder to pull data from firestore into my app with the code below. I am getting the error "streamusers and "userslist" are not defined as well as "testuser" is not a type. Here is a picture of my…
James Roth
  • 81
  • 1
  • 2
  • 12
0
votes
1 answer

Trying to add provider to automatically update new user info from firestore

I have made a simple profile page that shows a user's profile picture, name and stats (all pulled from a firestore database). I am now trying to implement provider so that the profile page will automatically update when new collections are added to…
James Roth
  • 81
  • 1
  • 2
  • 12
0
votes
1 answer

How to make Provider and Navigator work together?

I use Provider for state management and for separate business logic from UI. I have put some Provider above MaterialApp so can access everywhere in app (for example user info). But You don’t want to place ChangeNotifierProvider higher than…
FlutterFirebase
  • 2,163
  • 6
  • 28
  • 60
0
votes
0 answers

How do I setup multiple ChangeNotifierProvider of the same ChangeNotifier?

I have a class that extends ChangeNotifier, like this: class NovelNotifier extends BaseNotifier { List novels = []; Future addListNovelByCategoryID({ @required String id, int page = 1, int sort = 0, int status = 0, …
Joe Ng
  • 91
  • 2
  • 7
0
votes
1 answer

how to pass data from another provider with more than 1 value?

I'm using provider flutter package , but I wanna get the data from another provider and there's an example of doing it using ChangeNotifierProxyProvider. But how do I pass more than 1 value in builder properties because in the official docs is just…
0
votes
1 answer

How to prevent Provider from dispose model?

On app homepage I set up Model2 which make API call for data. User can then navigate to other page (Navigator.push). But I want make API call from Model2 when user press back (_onBackPress()) so can refresh data on homepage. When I make call, it…
FlutterFirebase
  • 2,163
  • 6
  • 28
  • 60