当前位置:网站首页>[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!')),
)
边栏推荐
- pycharm 打开多个项目的两种小技巧
- JS - DataTables control on the number of displays per page
- Ext4 file system opens dir_ After nlink feature, link_ Use link after count exceeds 65000_ Count=1 means the quantity is unknown
- 李沐d2l(四)---Softmax回归
- jvm命令归纳
- 2B和2C
- 力扣链表题
- 2022 mobile crane driver test question simulation test question bank simulation test platform operation
- 760. String length
- Force button list question
猜你喜欢

Unity topdown character movement control

jvm命令归纳

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

【Mysql】Mysql锁详解(三)

What is the difference between NFT and digital collections?

C# Serialport的发送和接收

Qtcreator reports an error: you need to set an executable in the custom run configuration

Sending and receiving of C serialport

Server memory failure prediction can actually do this!

The child and binary tree- open root inversion of polynomials
随机推荐
220. Presence of repeating element III
Use of off heap memory
基于序的评价指标 (特别针对推荐系统和多标签学习)
CF1481C Fence Painting
Hbuilderx runs the wechat developer tool "fail to open ide" to solve the error
LeetCode三数之和问题
838. 堆排序
(2006, MySQL server has gone away) problem handling
Study notes of canal
滑动窗口、双指针、单调队列、单调栈
MySQL 强化知识点
“No input file specified “问题的处理
神经网络与深度学习-6- 支持向量机1 -PyTorch
围棋智能机器人阿法狗,阿尔法狗机器人围棋
布隆过滤器
李沐d2l(五)---多层感知机
Pat grade a a1013 battle over cities
Qt | 关于如何使用事件过滤器 eventFilter
Thread Join 和Object wait 的区别
jvm命令归纳