当前位置:网站首页>Shutter control layout
Shutter control layout
2022-06-24 00:05:00 【Front end small tips】
Spacer
The initial state
- Set up three buttons , Sequential arrangement
- stay AB Add a line between the two buttons
Spacer() - stay BC Add a line between the two buttons
Spacer()
summary
Spacer() It's the effect of a spring , Maximize the distance between two controls . ( It works only when the page is not slidable )
Flex
Flex yes Row and Column The parent component of . Flex Component can arrange its subcomponents horizontally or vertically , If you know the direction of the spindle , Use Row or Column It will be more convenient , because Row and Column Inherit from Flex, The parameters are basically the same , So you can use Flex Basically, all the places can be used Row or Column.Flex Its function is very powerful , It can also be with Expanded Components cooperate to achieve flexible layout .
Expanded
You can scale “ Expansion ” Row、Column and Flex The space occupied by the subcomponents .
const Expanded({
int flex = 1,
@required Widget child,
})flex The parameter is the coefficient of elasticity , If 0 or null, be child There is no flexibility , That is, the space that will not be occupied by expansion . If it is greater than 0, be-all Expanded According to it flex The proportion of the spindle to divide all the free space .
With 1:1:2:2 The proportion of , array A , Space occupying blank , B , C
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
flex: 1,
child: RaisedButton(
color: Colors.yellow,
splashColor: Colors.green,
onPressed: () {},
child: Text("A"),
textColor: Color(0xffFfffff),
padding: EdgeInsets.all(8),
elevation: 5,
highlightColor: Color(0xffF88B0A),
),
),
Spacer(
//Spacer The function of is to occupy a specified proportion of space
flex: 1,
),
Expanded(
flex: 2,
child: RaisedButton(
color: Colors.green,
splashColor: Colors.green,
onPressed: () {},
child: Text("B"),
textColor: Color(0xffFfffff),
padding: EdgeInsets.all(8),
elevation: 5,
highlightColor: Color(0xffF88B0A),
),
),
Expanded(
flex: 2,
child: RaisedButton(
color: Colors.blue,
splashColor: Colors.blue,
onPressed: () {},
child: Text("C"),
textColor: Color(0xffFfffff),
padding: EdgeInsets.all(8),
elevation: 5,
highlightColor: Color(0xffF88B0A),
),
),
],
),
),Flexible
Flexible It's a control Row、Column、Flex How the subcomponents are laid out .
Flexible Components can make Row、Column、Flex And other subassemblies have the ability to fill the available space in the direction of the spindle ( for example ,Row In the horizontal direction ,Column In the vertical direction ), But it's connected to Expanded Different components , It doesn't force subcomponents to fill free space .
Three controls flex All are 1, The third control on the left is Flexible, The third control on the right is Expanded ( Other attributes are as like as two peas )
It can be seen that :
Row、Column、Flex Will be Expanded open , Full of spindle free space .
Flexible It doesn't force subcomponents to fill the available space , What is the actual size of the subcomponent , It's just how big .
Particular attention
Expanded、Flexible Only in Row、Column Components use .
Expanded、Flexible stay “Container、Padding、Stack” An error will be reported in the component : The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type Fle
Padding
Padding It can hold one subcomponent , Add your own inner margin to limit the child's component footprint , The core attribute is padding.
Container(
color: Colors.red,
width: 200,
height: 150,
child: Padding(
padding: EdgeInsets.all(20),
child: RaisedButton(
color: Colors.blue,
splashColor: Colors.blue,
onPressed: () {},
child: Text("C"),
textColor: Color(0xffFfffff),
padding: EdgeInsets.all(8),
elevation: 5,
highlightColor: Color(0xffF88B0A),
),
),
),About Padding and Expanded
- For visual elements with fixed spacing , Can pass Padding Pack it .
- For visual elements of variable size , Can pass Expanded Control to fill the empty area of the parent container
边栏推荐
- 抖音实战~手机号密码一键注册登录流程(限制手机终端登录)
- 合成大西瓜小游戏微信小程序源码/微信游戏小程序源码
- Different objects use the same material and have different performances
- Classical Chinese can be programmed???
- Six complete open source projects, learning enough at a time
- Detailed explanation of index invalidation caused by MySQL
- Leetcode - linked list written test questions
- B2B transaction management system of electronic components industry: improve the data-based driving ability and promote the growth of enterprise sales performance
- String s = new string ("XYZ") how many string objects are created?
- 依赖倒置原则
猜你喜欢

抖音实战~密码找回

docker 部署redis

APP性能优化之启动流程分析

Application of acrel-3000web power management system in Duba Expressway

docker 部署redis

【数字信号】基于matlab模拟窗函数频谱细化【含Matlab源码 1906期】

Docker redis cluster configuration

Android AIDL:跨进程调用Service (AIDL Service),kotlininvoke函数

Flux in three dimensional vector field

Test - use case - detail frenzy
随机推荐
What is the difference between overload and override?
Another short video app with high imitation and eye opening
Usage of go in SQL Server
Docker Deployment redis
组合总数II[每个元素只能用一次 + 去重复解集]
String s = new string ("XYZ") how many string objects are created?
物联网卡设备接入EasyCVR,如何查看拉流IP以及拉流时间?
Total number of combinations ii[each element can only be solved by + once]
How to ensure reliable power supply of Expressway
What are the good solutions for industrial control safety of production line
The group procurement management system of daily chemical supplies industry changes the traditional procurement mode and reduces the procurement cost
点乘和叉乘
暑假第一周
【面试经验包】面试被吊打经验总结(一)
docker redis集群配置
Under the background of aging, the comprehensive energy efficiency management platform escorts hospitals
PMP Exam related calculation formula summary! Must see before examination
Different objects use the same material and have different performances
UART protocol timing summary
Generate all possible binary search trees