Questions tagged [statefulwidget]

339 questions
0
votes
2 answers

Why is didChangeAppLifecycleState is being called twice in two different views

I have two stateful widgets: Widget1 and Widget2. Both defines the didChangeAppLifecycleState method. When there is a change in the lifecycle of Widget1, it's corresponding didChangeAppLifecycleState method is being called, but that for Widget2 is…
Noor
  • 19,638
  • 38
  • 136
  • 254
0
votes
1 answer

How to have entry variable in a stateful widget?

I'm just beginning to use firestore, and in the same time learning to use flutter and dart. I have two widgets : a stateless one and a stateful one, both returning the age of a user in a collection 'users'. The stateless one has the user id as…
Crapul
  • 15
  • 3
0
votes
1 answer

How to force a page rebuild with setStage() every time the dropdown button is changed? (Flutter)

I am trying to implement a dropdown button that let users switch between languages for my app, upon which the corresponding Webview containers will change to match the selected languages. I tried to implement this by creating a _renderWebviewBox1()…
0
votes
0 answers

Passing Value to Child - Flutter

In the below code I am passing value to WeeklyEventContaier before passing value I am checking value of _selectedButtonIndex if it is 2 as i am setting it on pressing elevated button but while receiving in WeeklyEventContaier i am getting as 0…
0
votes
1 answer

How to toggle open and close sub menu in each item of a list

I have a list of items. Each item has a button to show a sub-menu to do some action. I want to show only a sub-menu and hide others. When I tap an IconButton it shows and hides a sub-menu and works correctly but when another item sub-menu is open…
zex_rectooor
  • 692
  • 7
  • 26
0
votes
0 answers

How to use ProgressHUD show() and Dismiss() as widget in flutter app?

In below code for Home and Invoices I have implemnted ProgressHUD show() and dismiss() to show loader.Now I have to implement this ProgressHUD show() and dismiss() loader at the end where returning center with circular progress indicator widget. How…
0
votes
0 answers

How to prevent ListView.builder widget from rerendering when item is clicked

I am using a ListView builder widget inside a stateful widget class to display a categories menu. Inside this categories menu I created a method which is passed as parameter to CategoryItem class to handle the click event. Inside the CategoryItem…
Razvan22
  • 153
  • 2
  • 12
0
votes
0 answers

How do I update the ElevatedButton content right after it's clicked?

I am having an issue with the setState and I'm not sure what is the issue. What I'm trying to do is to update the fields after the click of a button. Please see my code below. The turn indicator that I have implemented works, so the state is…
Kostek
  • 1
  • 1
0
votes
0 answers

Are there any problems with this use of a Provider instead of a StatefulWidget?

class Example extends StatelessWidget { final List children; const Example({super.key, required this.children}); @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: (_)…
Ринат
  • 96
  • 1
  • 2
0
votes
1 answer

can a class with non-const constructor be a widget's child? for example a State object being a child of Center or materialApp

i tried to pass a State object to Counter widget as a child, I get the following error:- Error compiling to JavaScript: /tmp/dartpadWVXESU/lib/main.dart:59:18: Error: Cannot invoke a non-'const' constructor where a const expression is expected. Try…
0
votes
1 answer

I cant update the UI or widgets even with the StatefulWidget

I want to update the height of the first alertDialog right after I press the "increse the height" in the secoundDialog but it didn't change this is my code: class MyWidget extends StatefulWidget { const MyWidget({super.key}); @override …
ali ma
  • 5
  • 2
0
votes
1 answer

Initializing non-mutable fields in Stateful Widgets in Flutter

When creating a stateful widget in flutter, you may want some fields of the widget to not be mutated. In that case, I'm having trouble trying to figure out if it is better to always reference those fields from the state's widget reference, or if…
anqit
  • 780
  • 3
  • 12
0
votes
1 answer

Differences between AnimatedBuilder and StatefulWidget in Flutter?

From my point of view, all animations continuously render the widget with some often-changed value. For example, a spinning hand on a clock has a value called 'angle' to indicate its position. In Flutter, it seems that StatefulWidget is enough for…
Yang_____
  • 117
  • 8
0
votes
1 answer

What is the proper way to fetch a Future variable within my flutter stateful widget

How do I make sure my batchNo gets updated for every iteration in my for loop? I am confused with the 'right' way of tackling this problem. I am guessing I am supposed to initialise batchNo locally and update it as I go instead of fetching it every…
Joey Leo
  • 17
  • 6
0
votes
1 answer

Initializing Flutter Stateful Widget: Why is it discouraged to pass initial values to `State` constructor?

Currently, when I would like initial values of a stateful widget to be configurable, I follow a pattern that looks like class MyWidget extends StatefulWidget { final String? initialValue; MyWidget({ this.initialValue }); @override…
anqit
  • 780
  • 3
  • 12