Questions tagged [statefulwidget]

339 questions
1
vote
1 answer

Maintain state for StatefulWidget during build in Flutter

I have a list of stateful widgets where the user can add, remove, and interact with items in the list. Removing items from the list causes subsequent items in the list to rebuild as they shift to fill the deleted row. This results in a loss of state…
Ben
  • 1,132
  • 1
  • 15
  • 35
1
vote
1 answer

How to show local string in StatefulWidget?

I've learned How to use i18n via StatelessWidget for my flutter practice, but still not work via StatefulWidget. I can simply replace the following code title: new Text(S.of(context).title) with a const String, for example: title: const Text("A…
0
votes
2 answers

Managing Widget Rebuilds in Flutter: Child Should Not Rebuild with Parent

I'm working on a Flutter project and facing an issue related to widget rebuilds. I have a parent widget and a child widget. When the parent widget rebuilds due to state changes, the child widget also rebuilds, which I want to avoid. Both parent and…
0
votes
1 answer

Passing data to a stateful widget

Why is this not working when I try to pass data from a TextEditingController in one screen to a Stateful widget in another screen? Here is where I am passing the data in screen 1: Navigator.push( context, …
LostTexan
  • 431
  • 5
  • 18
0
votes
1 answer

changing state of widget is not reflected, using flutter

i have a login page where the password field has an "obscure" ability which is found in the buildInputForm defined below, to hide and show the password string if clicked, it use to work fine but now, the action is not reflected on the screen, i…
kawthar
  • 15
  • 5
0
votes
2 answers

How to maintain page state?

I am using Flutter 3 and go_router v10.0.0 to develop a program. This program uses the bottomNavigationBar(PageA, PageB, PageC), I hope that after these pages are routed back and forth, the pages can still maintain their state. For example, pageA is…
0
votes
0 answers

StateFull Widget Error - Classes can only extend other classes

I keep getting this error from my statefullwidget (Classes can only extend other classes.). I have also attched the status of my flutter doctor. I have updated my flutter app, I have also run flutter clean & flutter pub get but I am keep having…
0
votes
1 answer

Why is IconButton a stateless widget in Flutter, rather than being a stateful widget?

In the flutter documentation, it states "A stateless widget never changes. Icon, IconButton, and Text are examples of stateless widgets. Stateless widgets subclass StatelessWidget. A stateful widget is dynamic: for example, it can change its…
987Lan
  • 1
  • 2
0
votes
3 answers

Calling a stateful widget's method from another stateful widget

I'm new in Flutter, and recently I have encountered with a challange. I have the following files: main.dart import 'package:chatgpt_chat/testpage.dart'; import 'package:flutter/material.dart'; void main() => runApp(const TestAPP()); class…
0
votes
1 answer

How can I call setState in a function that is a parameter

when running the application I get the following error where the setState() function is: (https://i.stack.imgur.com/kYQFF.png) Here is my code for the main file: import 'package:flutter/material.dart'; import 'quotes.dart'; import…
MpofuO
  • 7
  • 2
0
votes
0 answers

Calling function in State from another file in flutter

I have a flutter project that I am working on. I have a widget that I need to be able to rebuild (Stateful Widget). But the problem is, I also need to be able to have a variable that changes during its lifetime and a function that I can call from…
maybrother
  • 44
  • 5
0
votes
0 answers

Flutter / Dart: Filling a form with a data object from and triggered by another screen

I have an app with two stateful pages: ListPage and InsertPage. When the user double clicks on an item in the ListPage, the InsertPage shall open and allow him to edit the data record he clicked on. Here are relevant code fragments: class ListPage…
Rasputin221
  • 51
  • 1
  • 3
0
votes
1 answer

Infinite loop from setstate function in flutter

I'm getting infinite loop when I call setstate function in the stateful widget in the below code. When I remove it, it stops the loop but then I won't get my widget updated so I need to use setstate to update my widget but I can't find a way out of…
0
votes
1 answer

Make widget take up a little less than available space (to account for widget above the keyboard)

Is there a way to have a widget body take up a little less than the available space when the keyboard shows up (to account for a BottomSheet fixed right above the keyboard? I have a bottom sheet that I am displaying whenever the keyboard is…
Charlie Page
  • 541
  • 2
  • 17
0
votes
1 answer

Best way to fire up an event once even if the parent rebuilds the child?

Say you have a stateful widget (name it ÌnterstitialAd) which implements a Google AdMob interstitial ad; you placed it in the parent splash screen in the hope it shows the ad up. Unfortunately, the splash makes some setState() hence triggering the…
Stéphane de Luca
  • 12,745
  • 9
  • 57
  • 95