当前位置:网站首页>[shutter -- layout] detailed explanation of the use of align, center and padding
[shutter -- layout] detailed explanation of the use of align, center and padding
2022-07-26 09:19:00 【Kevin-Dev】

List of articles
This paper mainly introduces Flutter In the layout Padding 、Align as well as Center Control .
Align
1. brief introduction
Development at other ends ,Align Generally, it is regarded as the property of a control , It is not taken out as a separate control .Align The functions implemented by itself are not complex , Set up child The alignment of , For example, center 、 On the left, on the right, etc , And according to child Adjust your own size .
2. attribute
alignment: Alignment mode , Generally, the system default 9 Ways of planting , But it's not the only thing 9 Kind of , For example, the following definitions . The system provides 9 The two ways are only pre-defined .
widthFactor: Width factor , If set ,Align The width of is child Multiply the width of by this value , It can't be negative .
heightFactor: Height factor , If set ,Align The height of child Multiply the height of by this value , It can't be negative .
3. example
1. design sketch 
2. Code
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({
Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: Text('Align'),
),
body: Container(
height: 120.0,
width: 120.0,
color: Colors.blue.shade50,
child: Align(
alignment: Alignment.topRight,
child: FlutterLogo(
size: 60,
),
),
)
)
);
}
}
Center
1. brief introduction
Center Inherited from Align, It's just that alignment Set to Alignment.center, Other properties such as widthFactor、heightFactor, Layout behavior , Both with Align Exactly the same as , Here is no longer a separate introduction .Center Source code is as follows , No settings alignment attribute , Because Align The default alignment is centered .
class Center extends Align {
/// Creates a widget that centers its child.
const Center({
Key key, double widthFactor, double heightFactor, Widget child })
: super(key: key, widthFactor: widthFactor, heightFactor: heightFactor, child: child);
}
Padding
1. brief introduction
Padding stay Flutter There are also many in use , As a basic control , Very single function , Set... For child nodes padding attribute . Anyone who has written about other terminals knows this attribute , Is to set the inner margin property , A blank area in the inner margin , It's also widget Part of .
2. attribute
padding:padding The type of EdgeInsetsGeometry,EdgeInsetsGeometry yes EdgeInsets as well as EdgeInsetsDirectional Base class of . Internationalization is not involved in practical use , For example, it is suitable for the Arab region , It's generally used EdgeInsets.EdgeInsetsDirectional Just look at the naming, you can know that it is related to the direction , Therefore, its four margins are not limited to up, down, left and right , It depends on the direction .
3. Sample code
new Padding(
padding: new EdgeInsets.all(8.0),
child: const Card(child: const Text('Hello World!')),
)
边栏推荐
- Object type collections are de duplicated according to the value of an attribute
- Vertical search
- 【ARKit、RealityKit】把图片转为3D模型
- Innovus is stuck, prompting x error:
- 语音聊天app源码——钠斯直播系统源码
- Two tips for pycharm to open multiple projects
- Nuxt - Project packaging deployment and online to server process (SSR server rendering)
- 谷粒学院的全部学习源码
- 【Mysql】一条SQL语句是怎么执行的(二)
- 【线上死锁分析】由index_merge引发的死锁事件
猜你喜欢

分布式跟踪系统选型与实践

220. Presence of repeating element III

Babbitt | metauniverse daily must read: does the future of metauniverse belong to large technology companies or to the decentralized Web3 world

2022 Shanghai safety officer C certificate examination questions and mock examination

【Mysql】一条SQL语句是怎么执行的(二)

volatile 靠的是MESI协议解决可见性问题?(上)

Study notes of dataX

【Mysql】认识Mysql重要架构(一)

Original root and NTT 5000 word explanation

CF1481C Fence Painting
随机推荐
MySQL strengthen knowledge points
2B和2C
[leetcode database 1050] actors and directors who have cooperated at least three times (simple question)
语音聊天app源码——钠斯直播系统源码
[MySQL] detailed explanation of MySQL lock (III)
Li Mu D2L (V) -- multilayer perceptron
滑动窗口、双指针、单调队列、单调栈
838. Heap sorting
OFDM 十六讲- OFDM
李沐d2l(六)---模型选择
多层嵌套后的 Fragment 懒加载实现
Mysql事务
力扣链表题
Qt | 关于如何使用事件过滤器 eventFilter
Introduction to excellent verilog/fpga open source project (30) - brute force MD5
209. Subarray with the smallest length
Innovus卡住,提示X Error:
Cat installation and use
Ext4 file system opens dir_ After nlink feature, link_ Use link after count exceeds 65000_ Count=1 means the quantity is unknown
分布式跟踪系统选型与实践