Questions tagged [flutter-widget]

594 questions
387
votes
17 answers

How to add a ListView to a Column in Flutter?

I'm trying to construct a simple login page for my Flutter app. I've successfully built the TextFields and log in/Sign in buttons. I want to add a horizontal ListView. When I run the code my elements disappear, if I do it without the ListView,…
Charles Jr
  • 8,333
  • 15
  • 53
  • 74
316
votes
6 answers

What is the difference between functions and classes to create reusable widgets?

I have realized that it is possible to create widgets using plain functions instead of subclassing StatelessWidget. An example would be this: Widget function({ String title, VoidCallback callback }) { return GestureDetector( onTap: callback, …
Rémi Rousselet
  • 256,336
  • 79
  • 519
  • 432
312
votes
16 answers

How to show/hide widgets programmatically in Flutter

In Android, every single View subclass has a setVisibility() method that allows you modify the visibility of a View object There are 3 options of setting the visibility: Visible: Renders the View visible inside the layout Invisible: Hides the View,…
user3217522
  • 5,786
  • 7
  • 26
  • 34
296
votes
6 answers

How to deal with unwanted widget build?

For various reasons, sometimes the build method of my widgets is called again. I know that it happens because a parent updated. But this causes undesired effects. A typical situation where it causes problems is when using FutureBuilder this…
Rémi Rousselet
  • 256,336
  • 79
  • 519
  • 432
275
votes
14 answers

The equivalent of wrap_content and match_parent in flutter?

In Android match_parent and wrap_content are used to resize the widgets automatically relative to their parent to the content the widget contains. In Flutter it seems by default all widgets are set to wrap_content, how would I change it such that I…
Faisal Abid
  • 8,900
  • 14
  • 59
  • 91
262
votes
24 answers

Adding a splash screen to Flutter apps

How would you approach adding a splash screen to Flutter apps? It should load and display before any other content. Currently, there is a brief flash of color before the Scaffold(home:X) widget loads.
Pieter
  • 4,721
  • 6
  • 19
  • 18
244
votes
10 answers

Flutter: Expanded vs Flexible

I've used both Expanded and Flexible widgets and they both seem to work the same. What is the difference between Expanded and Flexible?
user6274128
178
votes
4 answers

Flutter: How to correctly use an Inherited Widget?

What is the correct way to use an InheritedWidget? So far I understood that it gives you the chance to propagate data down the Widget tree. In extreme if you put is as RootWidget it will be accessible from all Widgets in the tree on all Routes,…
Thomas
  • 8,397
  • 7
  • 29
  • 39
132
votes
5 answers

How can I layout widgets based on the size of the parent?

Let's say you have a parent widget that might have a variable size. For example: var container = new Container( height: 200.0, // Imagine this might change width: 200.0, // Imagine this might change // Imagine content in this container will…
Dvdwasibi
  • 10,537
  • 7
  • 22
  • 22
123
votes
4 answers

Removing the drop shadow from a Scaffold AppBar in Flutter?

Is there a way to remove the drop shadow under the app bar (AppBar class) when using a Scaffold widget in Flutter?
Matt S.
  • 9,902
  • 6
  • 29
  • 25
119
votes
11 answers

Flutter: Trying to bottom-center an item in a Column, but it keeps left-aligning

I'm trying to bottom-center a widget at the bottom of a Column, but it keeps aligning to the left. return new Column( new Stack( new Positioned( bottom: 0.0, new Center( new Container(), ), ), ), ); The…
Mary
  • 18,347
  • 23
  • 59
  • 76
116
votes
20 answers

Looking up a deactivated widget's ancestor is unsafe

I am new in Flutter and I am trying receive data with a Dialog. When a click in textField the error of image2 appear... show(BuildContext context){ var dialog = Dialog( child: Container( margin: EdgeInsets.all(8.0), …
a2x
  • 1,261
  • 2
  • 6
  • 4
116
votes
11 answers

How do I remove Flutter IconButton big padding?

I want to have a row of IconButtons, all next to each other, but there seems to be pretty big padding between the actual icon, and the IconButton limits. I've already set the padding on the button to 0. This is my component, pretty…
Pablote
  • 4,745
  • 9
  • 39
  • 46
94
votes
8 answers

How to add scroll indicator in ListView

Is there any way to show the scroll indicator on the ListView? Here is my basic code: ListView.builder( itemCount: 50, itemBuilder: (context, index) => ListTile(title: Text("Item= ${index + 1}"),), )
user6274128
72
votes
13 answers

Flutter - how to remove default padding (48 px as per doc) from widgets (IconButton, CheckBox, FlatButton)

I am facing a problem with the default padding of the widgets (IconButton, CheckBox, FlatButton). I have searched a lot for this concern but with no success. In the above image, the outer blue rect is the actual size of these widgets and I have to…
Rahul Sharma
  • 12,515
  • 6
  • 21
  • 30
1
2 3
39 40