Questions tagged [flutter-change-notifier]

189 questions
26
votes
6 answers

Builder widget for ChangeNotifier in Flutter

Background A ValueNotifier has a ValueListenableBuilder widget. A Stream has a StreamBuilder widget. A Future has a FutureBuilder widget. Question What is the builder for ChangeNotifier? What I tried I tried using a ValueListenableBuilder with…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
18
votes
8 answers

The argument type 'Widget Function(BuildContext)' cant be assigned to the parameter type 'Widget Function(BuildContext, Widget)' Error in Flutter

This is a code: import 'package:flutter/material.dart'; import 'package:flutterapp/ui/pages/notes_home.dart'; import 'package:provider/provider.dart'; import 'package:flutterapp/ui/pages/splash.dart'; import…
Rohit Chaure
  • 181
  • 1
  • 1
  • 5
15
votes
1 answer

When is ChangeNotifier prefered over an Observable in Flutter?

I've been struggling to understand when ChangeNotifier is preferred over Rxdart's Observable, or streams in general. According to Flutter's docs: A class that can be extended or mixed in that provides a change notification API using VoidCallback…
Eliya Cohen
  • 10,716
  • 13
  • 59
  • 116
8
votes
3 answers

Reset provider data - Flutter

I'm using multiprovider in my application. Provider works perfectly, it stores the data and it provides perfect events when anything gets changed. Now, I've this scenario in my app -> User 1 loggedIn. Now when I'm adding a second account in the…
Harsh Patel
  • 1,056
  • 2
  • 10
  • 20
7
votes
1 answer

Flutter routing with Firebase Auth and ChangeNotifierProvider

I'm trying to make my flutter architecture as best as possible before diving into the features of my app. I have already made an app with firebase Authentification working, based on ChangeNotifierProvider : class MyApp extends StatelessWidget { //…
6
votes
3 answers

How can I stop my change notifier provider from rebuilding my parent material app when I am rendering my child material app?

I have a app class that returns a MaterialApp() which has it's home set to TheSplashPage(). This app listens to the preferences notifier if any preferences are changed. Then in TheSplashPage() I wait for some conditionals to be true and if they are…
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
5
votes
1 answer

Could not find the correct Provider<> with Hero animation Flutter

I'm pushing a new Route in my Gallery file to the Details file with a Hero animation. Everything is fine but when I'm calling the pop() inside the details file to go back to Gallery, I have a Provider error : flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS…
nicover
  • 2,213
  • 10
  • 24
4
votes
1 answer

Equivalent of ChangeNotifierProvider widget in Riverpod

Is there a widget equivalent of the ChangeNotifierProvider widget of Provider in Riverpod? The use case is to create a provider only when a page whose parent widget is ChangeNotifierProvider/or a page that has ChangeNotifierProvider in its widget…
3
votes
0 answers

How notifyListeners( ) actually works?

So, I have this class and I use the method addItem to add some item to my cart and itemsCount to have my total items show up in my cart icon in AppBar. My question is, how the itemsCount is update after I use addItem if itemsCount does not…
3
votes
0 answers

ChangeNotifierProxyProvider with an existing ChangeNotifier

I want to know how to use ChangeNotifierProxyProvider with an existing ChangeNotifier? The documentation clearly says DO use ChangeNotifierProvider.value to provide an existing ChangeNotifier. BUT ChangeNotifierProxyProvider doesn't have a .value…
AhWagih
  • 485
  • 5
  • 14
3
votes
1 answer

Having difficulty adding items to shopping cart - Flutter

I have my Cart model as below class Cart { String description; double unitCost; double amount; int quantity; String color; String imageURl; Cart({ this.description, this.unitCost, this.amount, this.color, …
3
votes
0 answers

ChangeNotifier listeners and dispose. Memory leaks?

I am curious if creation of new objects removes all attached listeners. Here it is simple code: class Notifier extends ChangeNotifier {} final notifier = Notifier(); for (int i = 0; i < 2; i++) { // Should I remove listeners before creation new…
BambinoUA
  • 6,126
  • 5
  • 35
  • 51
3
votes
1 answer

How can I have my change notifier trigger my alert dialog?

I have a notification service which is a change notifier. When the service recieves a notification it notifies all listners. I want to display a dialog when the listners get notified. So I do the following in my build method …
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
3
votes
1 answer

Flutter Provider: How do I listen to a change of a class field inside a class field?

Given the following Dart/Flutter class structure: import 'package:flutter/material.dart'; class A with ChangeNotifier { B _element1; B _element2; B get element1 => _element1; B get element2 => _element2; set element1(B value) { …
THE-E
  • 193
  • 3
  • 4
  • 21
3
votes
1 answer

Flutter await Provider to be ready inside multiprovider

I have a problem with synchronize Providers creation. I'm new to flutter, I'll try to explain better as i can. In my main.dart i have two providers one for the user auth and one for another widget into the code, it simply have a list to display. I…
Ruggero
  • 216
  • 1
  • 5
  • 15
1
2 3
12 13