当前位置:网站首页>[shutter -- layout] stacked layout (stack and positioned)
[shutter -- layout] stacked layout (stack and positioned)
2022-07-25 12:28:00 【Kevin-Dev】

List of articles
Flutter Use in Stack and Positioned These two components work together to achieve absolute positioning .Stack Allow subcomponents to stack , and Positioned For use in accordance with Stack Four corners to determine the location of the subcomponents .
Stack
1. brief introduction
Stack By analogy web Medium absolute, Absolute layout . Absolute layout is generally used less in mobile terminal development , But in some scenarios , It still has its function . Of course , It works Stack The absolute layout is complete , It can also be realized with other control combinations .
2. attribute
alignment: Alignment mode , The default is the upper left corner (topStart).
textDirection: Direction of text , Most don't need to deal with .
fit: Define how to set non-positioned Node size , The default is loose.
among StackFit There are the following :
- loose: The value of the child node is loose , It can be downloaded from min To max The size of the ;
- expand: Child nodes occupy as much space as possible , take max Size ;
- passthrough: Do not change the constraints of child nodes .
overflow: Whether the excess part is cut off (clipped).
3. example
1. design sketch

3. 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(' Lay out in layers '),
),
body: Center(
child: Stack(
alignment: const Alignment(0.6, 0.6),
children: <Widget>[
CircleAvatar(
backgroundImage: AssetImage('images/avatar.png'),
radius: 100.0,
),
Container(
decoration: BoxDecoration(
color: Colors.black45
),
child: Text(
'KevinDev',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
)
],
),
)
)
);
}
}
Positioned
1. brief introduction
Absolute positioning , Used to locate subcomponents
2. attribute
left、top、right、bottom: They stand for leaving Stack Left 、 On 、 Right 、 The distance between the lower four sides .
width、height: Specify the width and height of the element to be positioned .
notes :Positioned Of width、height It's a little different from other places , It's used to match left、top 、right、 bottom To locate components ,
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(' Lay out in layers '),
),
body: ConstrainedBox(
constraints: BoxConstraints.expand(),
child: Stack(
alignment:Alignment.center , // Specify no or partial positioning widget The alignment of
children: <Widget>[
Container(
child: Text("Hello world",style: TextStyle(color: Colors.white)),
color: Colors.blue,
),
Positioned(
left: 18.0,
child: Text("I am Kevin"),
),
Positioned(
top: 18.0,
child: Text("Your friend"),
)
],
),
)
)
);
}
}
边栏推荐
- 2022河南萌新联赛第(三)场:河南大学 I - 旅行
- Azure Devops(十四) 使用Azure的私有Nuget仓库
- Resttemplate and ribbon are easy to use
- Scott+scott law firm plans to file a class action against Yuga labs, or will confirm whether NFT is a securities product
- 【2】 Grid data display stretch ribbon (take DEM data as an example)
- Atomic atomic class
- cmake 学习使用笔记(二)库的生成与使用
- Build a series of vision transformer practices, and finally meet, Timm library!
- Create directories and subdirectories circularly
- Video caption (cross modal video summary / subtitle generation)
猜你喜欢

想要做好软件测试,可以先了解AST、SCA和渗透测试

阿里云技术专家秦隆:可靠性保障必备——云上如何进行混沌工程?

Pytorch project practice - fashionmnist fashion classification

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network

Feign use

2022.07.24(LC_6126_设计食物评分系统)

OSPF comprehensive experiment

Basic concepts of NLP 1

Microsoft azure and Analysys jointly released the report "Enterprise Cloud native platform driven digital transformation"

Those young people who left Netease
随机推荐
RestTemplate与Ribbon简单使用
Ansible
scrapy 设置随机的user_agent
1.1.1 欢迎来到机器学习
Atomic atomic class
想要做好软件测试,可以先了解AST、SCA和渗透测试
面试官:“同学,你做过真实落地项目吗?”
2022.07.24(LC_6124_第一个出现两次的字母)
2.1.2 application of machine learning
【五】页面和打印设置
1.1.1 welcome to machine learning
PyTorch进阶训练技巧
If you want to do a good job in software testing, you can first understand ast, SCA and penetration testing
【三】DEM山体阴影效果
Introduction to the scratch crawler framework
Eureka注册中心开启密码认证-记录
使用TensorBoard可视化训练过程
【7】 Layer display and annotation
Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network
Pytorch main module