Expanded (Flutter Widget of the Week)
Why Stack Overflow recommends it
Stack Overflow users link it in Flutter layout answers as the official quick explanation of Expanded, usually when fixing overflow, unbounded-constraint or space-sharing problems in Rows and Columns.
Recommended by 17 people across 15 different months, 2019 to 2023.
What it is
A 56-second entry in Google's Flutter Widget of the Week series explaining the Expanded widget, which changes the constraints passed to children of a Row or Column so they fill the available space. It is a short official explainer from the Flutter team.
What people said
Recommends onosecond · 2019-05 · Stack Overflow · on “Flutter: Expanded vs Flexible”
You may use Flexible to resize the widgets in rows and columns . It's mainly used to adjust the space of the different child widgets while keeping the relation with their parent widgets. Meanwhile, Expanded changes the constraints sent to the children of rows and columns ; it helps to fill the available spaces there. Therefore, when you wrap your child in an Expanded widget it fills up the empty spaces. Providing these videos from the Flutter's Official YouTube channel just to help out people, who might look for this in the upcoming future... Expanded: [this video] Flexible: [LINK]
Recommends Loolooii · 2019-06 · Stack Overflow · on “Flutter: cutting a row in "half"”
Expanded [LINK] takes as much space as available in this case horizontally. That means if you would use 2 Expanded widgets inside your Row , the space will be divided by half. Try this: Column( children: <Widget>[ Row( children: <Widget>[ Expanded( child: Text('first half'), ), Expanded( child: Text('second half'), ), ], ), Row( children: <Widget>[ Expanded( child: Text('first half'), ), Expanded( child: Text('second half'), ), ], ), Row( children: <Widget>[ Expanded( child: Text('full width'), ) ], ), ], ) Make sure you read more about Flutter widgets, for example watch this video (and other ones in this series): [this video]
Recommends Marcus Duarte · 2019-07 · Stack Overflow · on “Flutter - How to display two connected lists in single page?”
Use CustomScrollView you can learn more in this article [LINK] . More about CustomScrollView here [LINK] But if you want each list to have an independent scroll, you can use Column and the Expanded widget You learn more about Expanded widget here [this video] Sample code: @override Widget build(BuildContext context) { return Column( children: <Widget>[ Expanded( child: ListView( children: <Widget>[], ), flex: 2,//This widget get 2/3 of screen size. Default value is 1 ), Expanded( child: ListView( children: <Widget>[], ), flex: 1,//This widget get 1/3 of screen size ), ], ); }
Recommends LorenzOliveto · 2019-09 · Stack Overflow · on “Flutter: How to let several buttons in a line automatic match screen width?”
You could wrap the second row in an Expanded widget [this video] , in this way the buttons portion will take the whole remaining space after the text. Widget build(BuildContext context) { return Container( padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: Text("Input", style: Theme.of(context).textTheme.headline), ), Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: this.getButtons(), ), ) ], ), ); } Then you should also wrap the buttons in Expanded widgets, removing the fixed width from the SizedB
Recommends Tokenyet · 2019-09 · Stack Overflow · on “Flutter align widget to centre and another to the right - impossible”
Have you tried used `SizedBox` on Left side(empty) and Right side? Both set the `width` and Expand the middle `Column`, Or try to set `flex` factor as official's youtube tutorial [this video]
Recommends JJuice · 2020-01 · Stack Overflow · on “RenderFlex children having issue of unbounded height constraints”
The problem is that the Card widget has no size, indicated by the hasSize error. You could solve that by wrapping the Card widget with a Container or SizedBox widget and setting height and width properties on them or by wrapping the Card widget with an Expanded widget. Here’s a quick video on what Expanded does: Widget of the Week - Expanded [this video] EDIT: Checked the code in a Flutter project, but the error remains when you wrap the Card widget in an Expanded widget. So, use a Container or SizedBox , or any kind of widget where you can set the width and height explicitly.
Recommends Rodrigo · 2020-01 · Stack Overflow · on “Expanded TextField don't scroll when full”
Are you using flex factor? Expanded( flex: 2, child: Container( color: Colors.amber, height: 100, ), ), Watch this, maybe help Widget OF week [this video]
Recommends Luis Miguel Mantilla · 2020-03 · Stack Overflow · on “A RenderFlex overflowed by 86 pixels on the bottom in Flutter”
The problem is that you are using hardcode margins in a Column widget, that will give you problems in small devices too. You can fix that changing you Column Widget for a ListView Widget, but that is going to give you a Scroll Effect, I think you don't want that. So you can refactor that Column using Expanded Widget [this video] and a Stack can help in the first part of the Column, try the next: Column( children: <Widget>[ Expanded( flex: 1, child: Container( padding: EdgeInsets.symmetric(horizontal: 50), child: Stack( children: <Widget>[ Center( child: Text( "SET, MATCH AND CHALLENGE", style: TextStyle( fontSize: 40.0, ), ), ), Align( alignment: Alignment.bottomCenter, child: Text( "A simple, fu
Recommends scottstoll2017 · 2020-04 · Stack Overflow · on “How to set containers in row like content in linear layout Android”
Look into the Expanded class. You might want to start with the video for it in the "Widget of the Week" series on Youtube. [this video] When using Expandeds, I tend to make sure that all my flex values add to 100, and then use them like percentages. So here you would use a flex: 70 and the other one would be flex: 30
Recommends Chris Pi · 2020-05 · Stack Overflow · on “Placing ListTiles in a Row”
Ahhh, yes! I've now rewatched the Video about the Expanded Widget. For all who are intreested in that: [this video]