Questions tagged [statelesswidget]

121 questions
1
vote
1 answer

Flutter Stateless Widget initialize values by keeping the constructor as "const"

I want to map a List of Strings to a List of DropdownMenuItems in the Widget constructor. The parent widget passes a List of Strings to the child widget. The child widget must map this List of Strings to a List of DropdownMenuItems. I want to do…
Gipfeli
  • 197
  • 3
  • 8
1
vote
1 answer

StatelessWidget gets rebuilt even though parameters stay the same; notifyListeners() with ChangeNotifier

I've got two StatelessWidgets, one is a child of another. There is also a progress update function which updates the state in the external TransferState. Once updateProgress function is being called the TransferIndicator widget gets rebuilt…
Tom Raganowicz
  • 2,169
  • 5
  • 27
  • 41
1
vote
0 answers

draggableScrollableController not attached to a sheet after it has been attached

I'm trying to use a DraggableScrollableSheet inside a BlocBuilder so that when I navigate to a page I can do something like this: cubit.draggableScrollableController.animateTo( .5, // or 1.0 duration: Duration(seconds: 10), curve:…
MetaStack
  • 3,266
  • 4
  • 30
  • 67
1
vote
1 answer

Is this code writing method recommended in Flutter?

I installed Awesome Flutter Snippets and Flutter Snippets extension in VS Code. When I install these two extensions, I can use some keyboard shortcuts to generate widgets. When I type statelessW or stless in the code and hit enter, it generates…
My Car
  • 4,198
  • 5
  • 17
  • 50
1
vote
1 answer

How to interact with a child Stateful Widget from a parent Stateless Widget?

Context : Say I have a custom DisplayElapsedTime Widget which is Stateful and holds a Text Widget. With a Timer, every 1sec, the text value is updated with the current elapsed time given by a Stopwatch. And now, say I have a page which is Stateless…
1
vote
1 answer

Class and Stateless Widget

First of all I would like to say that I am new to Flutter. I don't understand the difference between class and stateless widget. I understand why I'm using stateful , because of setState. but why should I use statless instead of just class ?
aycha
  • 59
  • 1
  • 9
1
vote
1 answer

what is the difference between creating widget using widget class, and creating class widget that extend statelessWidget?

so i have this code: import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); // This widget is the root of your application. @override …
dx dx
  • 43
  • 1
  • 4
1
vote
0 answers

Flutter clean architecture with Bloc, RxDart and StreamBuilder, Stateless vs Stateful and dispose

I'm trying to implement a clean architecture with no dependency of the framework in the business' logic layers. The following example is a Screen with only a Text. I make an API Rest call in the repository and add the response to a BehaviorSubject…
Gilgamesh
  • 197
  • 2
  • 13
1
vote
2 answers

Flutter: How to call a function before onChanged Method from TextFormField gets called?

I have a reusable TextFormField Widget for decimal number inputs. If the user input a decimal number with a comma instead of a dot I want to replace it. So for that I created a reusable TextFormField Widget where I want to replace the comma with a…
Dalon
  • 566
  • 8
  • 26
1
vote
1 answer

Child Property in Stateful Widget

I've made some test widgets to illustrate a point that I'm having difficulty with in a much more complicated widget. I have the following widget: class TestListWidget extends StatefulWidget { Widget child; TestListWidget({Widget child}) { …
1
vote
0 answers

How to define variables in a stateless widget in flutter

I want to pass a variable from a statelesswidget to a stateful widget. But when I do so, i have to remove the const from the constructor of GameScreen. Which is generally not advised and will make the statelesswidget equivalent to a stateful widget…
Joel
  • 239
  • 3
  • 21
1
vote
1 answer

How to pass data to stateless widget calling from another stateless widget?

I am trying to pass some color info from one widget to another but I am not able to get that color in destination widget. I wanted to build a single class with some UI code in it and just call this class in my main widget so that I don't have to…
Abdullah
  • 123
  • 1
  • 1
  • 11
1
vote
3 answers

How to click the button in flutter to change the background image

I am a beginner in flutter, I don’t understand the concept of Widget very well. I want to set the background image as an unsplash random image, but I want to add a button to request a random image again when I click it, but I am confused about many…
Marshall
  • 47
  • 5
1
vote
2 answers

Pass variable from MaterialPageRoute to custom widget

A little bit of background: Flutter noob here, trying to build an Add To Favourites function. The list of items sits in a PHP/MySQL database which I access using http on FirstScreen. When user taps on one of the list items, they get redirected to…
1
vote
0 answers

how get variable value from this extends StatelessWidget in flutter_deep_linking-master / multi level project

I'm newbie, just how get variable value from this extends StatelessWidget in a flutter_deep_linking-master / multi level project using plugin URL launcher how get the variable value of ${person.pdf} and insert it in String link = variable; and put…
Patricio
  • 11
  • 2
1 2
3
8 9