Questions tagged [flutter-state]

369 questions
3
votes
2 answers

How to scope a provider in riverpod?

I'm starting to use riverpod and I'm trying to migrate my existing code which was using provider. With provider, the Providers were scoped in the widget tree. Only the children of the Provider widget could access its model. It says in the riverpod's…
Valentin Vignal
  • 6,151
  • 2
  • 33
  • 73
3
votes
2 answers

When to use .add() and when to use emit() in Flutter Bloc?

I am new to Bloc in flutter, any one can please explain when should I use add() and when to use emit in Blocs?
3
votes
1 answer

Flutter - cubit - changing boolean value inside cubit

I would like to change bool values from the cubit, but I can't figure out how to do it. What I want to achieve is, for instance: if (boolean value stored in cubit is true) "show widget A" : "show widget B" My code: class ChangeBoolCubit extends…
mmcib
  • 131
  • 1
  • 10
3
votes
2 answers

calling setState from the parent widget in flutter does not update the state

Parent Widget class _FamilyListPageState extends State { String initialValue = 'Search Families'; void eraseInitialValue() { <-------------- This function is passed down to the child widget setState(() { …
3
votes
4 answers

How to force initState every time the page is rendered in flutter?

I am adding some data into the SharedPreferenceson page2 of my app and I am trying to retrieve the data on the homepage. I have used an init function on page 1 as follows: @override void initState() { super.initState(); …
ag2byte
  • 191
  • 3
  • 11
3
votes
1 answer

Flutter : Drag Widgets across screen (Not Drag and Drop)

I want to just drag widgets across screen, not drag and drop. But, whenever I leave it and start dragging again, it starts getting drag from the position it started with. As if it was reset. My guess is build is called again and again, so it…
3
votes
1 answer

Riverpods with hooks Flutter - using Provider

Could someone give an example of additional state modifications in Riverpods preferably with riverpod_hooks - I'd like to be able to use it without making an additional widget, so for example: onPress: () { …
3
votes
2 answers

Flutter Riverpod StateNotifier load data on page build

I am developing a new application and testing Riverpod with state notifier and have a question about where I can load my initial data when I'm building a page. I have following state class: abstract class SalesOrderListState extends Equatable { …
Alex Bibiano
  • 633
  • 1
  • 6
  • 19
3
votes
1 answer

How can I refresh count value on my dashboard of Flutter Application? (BLoC Pattern is Followed)

For a Dashboard design as shown in image, I've to display various counts fetched from API. Each count will be fetched from different API by looking at the label. My developed Structure, DashboardScreen CustomBottomMenuOptionWidget(label) -…
Purvik Rana
  • 331
  • 7
  • 17
3
votes
1 answer

Can someone explain what are Slivers and Delegates in flutter and why to use them?

"Link to code" I was following the Flutter State Management tutorial and came across this. Please explain what are Slivers, Delegates. Especially this part that I have attached. class MyCatalog extends StatelessWidget { @override Widget…
rushikesh chaskar
  • 642
  • 1
  • 7
  • 12
2
votes
1 answer

flutter_reactive_value: Getting an Error with just Importing the Package

I followed the instructions for installing flutter_reactive_value as described here. flutter pub add flutter_reactive_value And I added the import on my main.dart: import 'package:flutter_reactive_value/flutter_reactive_value.dart'; That's as far as…
Steve3p0
  • 2,332
  • 5
  • 22
  • 30
2
votes
1 answer

How to update freezed state correctly using future provider?

Im using riverpod FutureProvider to fetch devices with API calls and try to persist them with StateNotifier in the state with custom state class. If i try to update the loading state i get following error. Any…
2
votes
1 answer

To safely refer to a widget's ancestor in its dispose() method

I want to build a math app with Flutter. It should have basic functions. However, I am facing the following issue: when my timer runs out and I am directed to the next page, the following error message appears: The following assertion was thrown…
aycha
  • 59
  • 1
  • 9
2
votes
1 answer

Issue with textFormField/TextField triggering unnecessary rebuilds when focused

On focus, my textFormFields or textFields trigger unnecessary rebuilds, spike resource drains & make emulator & computer slow or even unusable. I've done considerable research on this. It seems like quite an issue & I haven't been able to resolve…
RobbB
  • 1,214
  • 11
  • 39
2
votes
1 answer

Flutter toggle button using Getx for state management

I'm making a toggle button to switch between the unit system, I need to do it using Getx for state management. This code works, but its using setState() instead This is the (simplified) code: import 'package:flutter/material.dart'; import…
Gryva
  • 297
  • 1
  • 11
1 2
3
24 25