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

Flutter : Could not find the correct Provider

I am tying to implement Firebase Authentication in my flutter app, with the help of provider. First, I am checking whether the user is already signed in, if yes, i AM sending him to the home screen. Else I am sending him to the Login screen. Please…
PeakGen
  • 21,894
  • 86
  • 261
  • 463
0
votes
1 answer

How to create and update the value of Dynamic Widgets through Flutter Provider

So I am implementing something like below: class TempProvider extends ChangeNotifier(){ List _list = []; List _list; int _count = 0; int get count => _count; Future> getList()…
AverageCoder
  • 321
  • 6
  • 15
0
votes
1 answer

Do I need to use ProxyProvider - or restructure my data model?

This is my first flutter app - it's an Expenses splitter. Passing around callbacks was getting very complex, so I switched to Provider - but was getting errors which I think are because of my data model having dependencies (see snippet below). …
Kai
  • 15
  • 3
0
votes
0 answers

Flutter Provider child error: Could not find the correct Provider above this YouBeautyApp Widget

I'm just starting out with Flutter and Provider and I'm trying to wrap my head around rendering two different widgets depending on a user login state. I'm running the YouBeautyApp() as a child of ChangeNotifierProvider but I still get the following…
0
votes
1 answer

Flutter provider throwing error setState() or markNeedsBuild() called during build

I am trying to learn how to use the provider package, version 4.0+. I have copy-pasted solution provided by flutter team and run it on my emulator. The problem is, when I run it for the first time (cold start), I am getting the following error…
Robert J.
  • 2,631
  • 8
  • 32
  • 59
0
votes
1 answer

Flutter provider not updating state

I'm still relatively new to flutter and even newer to Provider so I may be entirely off with this but from what I've read it looks correct. General idea is there's a header widget with a button that will either open an endrawer or bring the user to…
Nate
  • 333
  • 3
  • 15
0
votes
1 answer

using flutter provider with removeWhere list function deletes the wrong items?

I am deleting a engine model via: delete(int id) { engines.removeWhere((eng) => eng.id == id); notifyListeners(); } } The interesting part here is that the engine with the passed id gets removed indeed correctly while debugging. But…
Pascal
  • 12,265
  • 25
  • 103
  • 195
0
votes
0 answers

Consumer of ChangeNotifierProvider is always null

The Machinemodel instance from the Consumer is always null. Why? App import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the…
Pascal
  • 12,265
  • 25
  • 103
  • 195
0
votes
1 answer

Flutter provider not allowing me to access data

I have set up a simple provider in my flutter application, which is as follows: import 'package:flutter/material.dart'; class Data1 { int data1 = 0; double _data2; var _arr = []; } class SendDataModel extends ChangeNotifier { List
Matt123
  • 293
  • 1
  • 4
  • 10
0
votes
1 answer

How to implement an API call linked to a Provider using SOLID principles in a Flutter app?

I am trying to refactor my Flutter weather application. It eventually calls an API to provide weather data based with a location as a parameter. Currently, I have : A WeatherJSONModel.dart which corresponds to the JSON response given by the API I…
m3y
  • 33
  • 7
0
votes
1 answer

ChangeNotifierProvider shows gray screen

I have the following code class to hold my items as follows: class ItemList extends ChangeNotifier { List items = [ { "id": "1", "type": "men", "liked" : true, "cuisine": "Americain", "img":…
Behrouz Riahi
  • 1,751
  • 2
  • 21
  • 42
0
votes
0 answers

How to properly use StreamProvider that rely on another StreamProvider?

I have pretty similar question with this: How to setup StreamProvider which take a param value from another StreamProvider? But the problem is that the RxDart already changed their code and I don't have enough reputation to comment on that…
leemuljadi
  • 410
  • 1
  • 3
  • 14
0
votes
0 answers

What is the best way to use Flutter provider with a firestore

I want to update my view on every database change using provider package, the problem is that whenever I use provider to update the view on every database change, it keeps updating the view every second even if there is no changes. What is the best…
0
votes
1 answer

Flutter / Inject.dart - Is it possible to simplify or generate code for a 'provided' class instantiation?

Been doing some research on Flutter Dependency Injection,and I kinda settled on Inject.dart However, I am having some trouble using inject. Is there any way to simplify instantitation of a injected class? I have this MyClass, which I need to…
0
votes
1 answer

Passing async data (GPS coordination) from FutureBuilder to Provider / Setting async constructor

I'm having trouble dealing with async data (namely user GPS coordination) input. I simplified my app to a calculator app below, which manages the state (a double) by provider. import 'package:flutter/material.dart'; import…
Wenhui Luo
  • 266
  • 3
  • 13