Questions tagged [flutter-riverpod]

166 questions
1
vote
2 answers

Best practice on how to write/update data from a Flutter provider

I'm fairly new to Flutter providers. I use Riverpod. I have a Future provider that provide some data from a JSON file - in the future it will be from a API response. import 'dart:convert'; import 'package:flutter/services.dart'; import…
bolino
  • 867
  • 1
  • 10
  • 27
1
vote
2 answers

Proper way to access Riverpod's state provider inside extensions in Flutter?

How to access counterProvider inside extension? import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; main() { runApp(const ProviderScope(child: MyApp2())); } class MyApp2 extends ConsumerWidget { …
Davoud
  • 2,576
  • 1
  • 32
  • 53
1
vote
1 answer

Why suffixIcon does not work with river_pod?

I'm preparing password-field with TextFormFieldand riverpod on flutter as followings. When the suffixIcon is tapped, the icon would change from solidEye to solidEyeSlash, accorging to the bool result of mask. Actually, the bool result is toggled…
SugiuraY
  • 311
  • 1
  • 9
1
vote
0 answers

Unable to watch TextEditingController in riverpod

I'm trying to watch to TextEditingController keyword provider is not updated. final textEditingController = Provider.autoDispose((ref) => TextEditingController()); final keyword = Provider.autoDispose((ref) { return…
Mohammad Alotol
  • 1,409
  • 15
  • 23
1
vote
1 answer

Flutter, riverpod StateProvider not uploading ui

I am using flutter riverpod, and I am watching a provider. But when I change the value of the provider, the build method is not being called. The build method is not called again when I call : …
RJB
  • 1,704
  • 23
  • 50
1
vote
2 answers

Riverpod Flutter: Multiple providers for one screen

I'm new to riverpod, and I want to check that I am doing things correct. I have a screen on my Flutter app where the use inputs lots of information about a session. Like start time, end time, notes, duration, date etc etc. All this data in the end…
RJB
  • 1,704
  • 23
  • 50
1
vote
1 answer

How to override a provider with a Mock for ChangeNotifierProvider in Riverpod?

I am using flutter_riverpod: ^1.0.3 I am trying to write a widget test. I have ChangeNotifierProvider like the code below final customerDataControllerProvider = ChangeNotifierProvider((ref) { return…
Alexa289
  • 8,089
  • 10
  • 74
  • 178
1
vote
2 answers

Riverpod in a class or outside of build Method?

I want to make a class and put similar methods together. Riverpod works using ref which is only available through extending but how to use it in bare class which doesn't have any extends and build methods. Model class User { final String uid; final…
0
votes
0 answers

In Riverpod 2.0 Flutter, is it possible to create multiple NotifierProvider?

Before Riverpod is using build_runner, it was possible to create multiple provider that using one class of (State)Notifier. like the code below, class Counter extends StateNotifier{ Counter(): super(0); void increment() =>…
Naduel
  • 63
  • 3
0
votes
0 answers

How to handle async calls by using Flutter Riverpod StateNotifier

Which of the following ways is the proper approach to handle async calls using Riverpod in Flutter? Should I worry about the getStringResult asynchronous call when the controller is being disposed as I do in approach B? Or shouldn't worry about the…
0
votes
1 answer

flutter Riverpod moving the parameters from a State Notifier class into a function inside the class

I'm new to flutter and very new to riverpod. I've just been helped with some code to use a countdown clock that can then be viewed on multiple pages using Riverpod. here is the Riverpod State Notifier. final countDownControllerProvider =…
Nomad09
  • 161
  • 8
0
votes
0 answers

how to use ref.refresh(provider) in global using flutter_riverpod

i am using flutter_riverpod plugin usually i am using ref.refresh(provider) within the stful widget but How could i use it out of stful widget examply // here in global how could i use it ? stfl{.....}
Mohammed Hamdan
  • 1,006
  • 5
  • 23
0
votes
1 answer

Combining Riverpod Providers Bidirectionally

How can we access a method from the being wrapped riverpod provider? ContentProvider can access user value from UserProvider by using "watch". There is no problem for this direction. On the other hand, UserProvider also needs access to the methods…
0
votes
2 answers

Flutter Riverpod show CircularProgressIndicator while waiting for future ro resolve

I want to show CircularProgressIndicator while waiting for future to resolve using flutter_riverpod, here is my code snippet. But it's not showing, I am using ConsumerStatefulWidget is this right way to do it? ElevatedButton( …
Beqa Latsabidze
  • 212
  • 4
  • 12
0
votes
1 answer

Flutter with Riverpod and Websocket . Get the error: flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception:

I am trying to learn Riverpod. This code uses , flutter_riverpod, and web_socket_channel. The app connects to a WebSocket server to a IP address and on port 81, and uses the Riverpod library to manage the state of the app. The app has several…
Carlos Costa
  • 123
  • 3
  • 11