Flexible (Flutter Widget of the Week)
Why Stack Overflow recommends it
Stack Overflow users link it when answering Flutter layout questions about Flexible versus Expanded, flex factors, and fixing row or column overflow.
Recommended by 5 people across 5 different months, 2019 to 2023.
What it is
A 91-second Flutter Widget of the Week episode from the official Flutter channel explaining the Flexible widget. It shows how Flexible resizes children of Rows and Columns relative to their parent and to each other.
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: [LINK] Flexible: [this video]
Recommends Yash Dixit · 2020-10 · Stack Overflow · on “flutter: how to suit all the screen sizes with the same program?”
When I usually create a flutter app, for its responsiveness I usually use these points: Use of Expanded [LINK] , Flexible [this video] , and Spacer [LINK] Widgets when using Rows and Columns: All of these have a property called flex which is highly useful. Whenever I use rows or columns I use these widgets. Use of Layout Builder and Media Query widgets: These are there in the documentation: Creating responsive apps [LINK] (There are more articles on this flutter documentation which are recommended), can be used to know the screen size, the width, and the height, also how your apps function in different orientations. MediaQuery [LINK] gives the width and height as follows: double w = MediaQuery.of
Recommends zoli_a · 2021-03 · Stack Overflow · on “can somebody explain this statement form flutter?”
The default (main axis) size of the column or row is the minimum size to contain its children. Normally these children have a fix height. For example, if the column has 3 children with 50 height, the column's height is going to be 150. But flexible widgets are an exception. Flexible widgets calculate their sizes by dividing the available space by their flex factor. If the column containing the flexible widget is not constrained, this available space is infinity. So infinity/flexFactor is still infinity. (In practice you get an exception instead of an infinitely sized widget) The solution for this problem is to put the column or row widget into a fix sized widget. For example: you want to mak
Recommends Manishyadav · 2022-03 · Stack Overflow · on “Text overflow on Flutter”
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... 1. Expanded [LINK] 2. Flexible [this video] Example: Flexible( child: Text()), Expanded( child: Text()),
Recommends Moh. Absar Rahman · 2023-03 · Stack Overflow · on “how to set even size for all single and multi digit text in container?”
There are multiple ways you can set you can set even container size for all the container by the following ways. Using Expanded or Flexible Expanded Widget documentation: [LINK] Expanded Widget demonstration: [LINK] Flexible Widget documentation: [LINK] Flexible Widget demonstration: [this video] For your case it can be either Expanded or Flexible . Depends on your actual design and your plan. You need to play around with Expanded and Flexible so that you can get clear understanding. For now I have written the snippet using Expanded . For adjusting the space, you can check the widget named Spacer Spacer widget documentation: [LINK] Spacer Widget demonstration: [LINK] Note: I did not adjust the sp
Cites Isti01 · 2020-02 · Stack Overflow · on “How to apply flex in flutter”
Widgets inside a Flex widget (eg. Column, Row ) can be wrapped in the Flexible widget. The Flexible widget has flex propery. Flutter has 3 flexible widgets: Flexible [this video] , Expanded [LINK] and Spacer [LINK] return Container( child: new Row( children: <Widget>[ Flexible( flex: 1 /*or any integer value above 0 (optional)*/, child: Column( children: <Widget>[ Expanded( flex: 1 /*or any integer value above 0 (optional)*/, child: new Text("Hello World")), ], ), ), new Column( children: <Widget>[ new Text( "This is a long text this is a long test this is This is a long text this is a long test this is This is a long text this is a long test this is This is a long text this is a long test this i
Cites Kherel · 2020-08 · Stack Overflow · on “Flutter Icons in Row "right overflowed by X pixels"”
There are many options who to deal with it, depending on what you need. I've add two of them First. Wrap every icon in Flexible Widget Flutter Widget of the Week about it [this video] [LINK] bool isSelected = false; @override Widget build(BuildContext context) { return GestureDetector( onTap: () { setState(() { isSelected = !isSelected; }); }, child: Center( child: AnimatedContainer( padding: isSelected ? EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0) : EdgeInsets.symmetric(vertical: 12.0, horizontal: 30.0), width: isSelected ? 48 : MediaQuery.of(context).size.width * 0.85, child: isSelected ? Icon(Icons.favorite) : Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ _icon
Cites Celt K. B. · 2021-03 · Stack Overflow · on “How to make a image fit in 1/3rd of screen in flutter”
You can use Flexible: [LINK] [this video] Column(children: [ Flexible( flex: 1 child: Container(color: Colors.blue), Flexible( flex: 2 child: Container(color: Colors.green), ), ]);
Cites Kent · 2021-05 · Stack Overflow · on “Child inside Column shrinkwrap when height is short and scrollable when height is overflow”
Here is your example. The key you are missing is a Widget called Flexible . It's an important Widget for these types of cases you will learn about it after you have been doing Flutter dev for a while. [LINK] import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @override _