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
4
votes
2 answers

Combining FutureProviders using a FutureProvider RiverPod

I am currently making the Udacity Sunshine project in Flutter. I have two different provider to fetch current temperature and daily forecasts. I want to combine the two providers and make a new single provider called weatherProvider. File:…
Ariel
  • 2,471
  • 1
  • 26
  • 43
4
votes
1 answer

How to override the state of a Riverpod StateNotifier for testing

I want to override my StateNotifierProvider state manually for testing. Overriding providers can be done using ProviderContainer or ProviderScope. But it only gives the option to override the notifier, not the state. My question is how should I…
NirmalCode
  • 2,140
  • 1
  • 14
  • 19
4
votes
0 answers

Can't read provider data inspite of having it in an ancesstor widget. Flutter

I just started with Provider package of flutter, I learnt that we have to provide the provider in a parent class and that is what is did. But I am still getting this error. I have a feeling it has something to do with the route generator. Any help…
Sayanc2000
  • 212
  • 2
  • 6
4
votes
4 answers

Flutter Provider. How to have multiple instances of the same provider type?

So I’m a little confused about how to port an application using setstate to provider. Let’s say I have a person model which extends provider. Now I also want to have multiple person reports. Each report has it’s own properties such, title, created…
Lee
  • 381
  • 1
  • 7
  • 16
4
votes
4 answers

Flutter - How to wipe provider data after user signed out from app?

I am using provider for state management in my flutter application. I have implemented provider using Multiprovider. I want to wipe provider data when the user signed out from the app I have read out this comment but don't understand it well.
Ranjit Shrestha
  • 622
  • 6
  • 24
4
votes
1 answer

_InternalLinkedHashMap' is not a subtype of type 'String' when connecting to API

I'm trying to do a login to my RESTAPI with node.js. But it gives me an error saying: [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: type '_InternalLinkedHashMap' is not a subtype of type 'String' I'm using…
4
votes
2 answers

How do avoid markNeedsBuilder() error using Flutter_Riverpod and TextEditingControllers on TextFormFields?

The form below is using ConsumerWidget from the flutter_riverpod package to watch for updates on first/last name fields in a firebase stream provider. Then using TextEditingControllers I am both setting the watched text values in the fields and also…
Zelf
  • 1,723
  • 2
  • 23
  • 40
4
votes
4 answers

Flutter - Duplicate GlobalKey detected in widget tree

Refer to this Duplicate GlobalKey detected in widget tree , i still have struggle with duplicate key while navigate from Screen A , to Screen B and Navigatie again to Screen A LoginPage class LoginPage extends StatefulWidget { @override …
Don Key
  • 105
  • 1
  • 2
  • 6
4
votes
2 answers

Flutter api login using riverpod

I'm trying to use riverpod for login with a laravel backend. Right now I'm just returning true or false from the repository. I've set a form that accepts email and password. The isLoading variable is just to show a circle indicator. I've run the…
stalwart1014
  • 451
  • 1
  • 9
  • 29
4
votes
0 answers

Flutter : How to update widget state from background / service?

I'm new in flutter. I created an service with the android alarm manager plugin to get data from json Api every x minutes. That's ok. I use a stateful widget with streambuilder + futurebuilder to fetch my json data. At the first load, data are…
4
votes
3 answers

Flutter/Riverpod: UI not updating on state change within a StateNotifierProvider

The UI of my app is not updating when I know for a fact the state is changing. I am using the watch method from Riverpod to handle this, but the changes don't take effect unless I do a hot reload. I have a class HabitListStateNotifier with methods…
wolfeweeks
  • 355
  • 4
  • 12
4
votes
0 answers

Flutter: Asking Location permission pauses all app execution, how to let it run asynchronously

When my app requests location permission the entire app stops until the dialog is complete (e.g. if the permission dialog pops up during a page transition the transition will freeze mid transition until the dialog is resolved). Literally it causes…
Shazamo Morebucks
  • 478
  • 1
  • 8
  • 19
4
votes
1 answer

Provider NotifyListeners not updating consumers

I'm pretty new to flutter and really, really want to use provider to pass data around, but I just can't get it to work. I think I have everything set right, but for some reason when I notify listeners, my app doesn't refresh. All I'm trying to do…
steveny909
  • 95
  • 1
  • 3
  • 10
4
votes
1 answer

Flutter Riverpod - using read() inside build method

Suppose I want to initialize a text field by using the initialValue: property on a TextFormField, and I need my initial value to come from a provider. I read on the docs that calling read() from inside the build method is considered bad practice,…
user3703367
4
votes
1 answer

How to create a StreamProvider and subscribe to it later, Flutter

I have an issue where I want to create a MultiProvider with some different providers, the problem is that two of those are StreamProviders that require first to have a firebase auth login, and after that subscribe to a Stream in firebase based on…
Miguel Chavez
  • 161
  • 1
  • 2
  • 14