当前位置:网站首页>【Flutter组件】Expanded详解
【Flutter组件】Expanded详解
2022-07-22 00:08:00 【It一zhai男】
Expanded特点
- 只能在
Column
,Row
,Flex
以及它们的子组件,这里指的是子组件而不是子结点,是指继承Column
,Row
,Flex
的子组件。 Expanded
的父结点必须是Column
,Row
,Flex
以及它们的子组件,不能是Column->Container->Expanded
(表示结点路径)- 在使用
Expanded
时,如果在它的上层结点中有List
类型的结点,比如SingleChildScrollView
,或者ListTile
等,其滑动方向应该与Expanded
填充方向不同,不然会报错。 Expanded
作用是,填充剩余空间。
class Expanded extends Flexible {
/// Creates a widget that expands a child of a [Row], [Column], or [Flex]
/// so that the child fills the available space along the flex widget's
/// main axis.
const Expanded({
Key? key,
int flex = 1,
required Widget child,
}) : super(key: key, flex: flex, fit: FlexFit.tight, child: child);
}
flex
:表示弹性系数,弹性系数越高,所占空间越大,类似于Android
原生的LinearLayout
的weight
属性。child
:子节点
示例
flutter
代码
Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Column(
children: [
Expanded(
flex: 1,
child: Container(
color: Colors.black,
)),
Expanded(
flex: 2,
child: Container(
color: Colors.red,
)),
Expanded(
flex: 1,
child: Container(
color: Colors.blue,
))
],
), // This trailing comma makes auto-formatting nicer for build methods.
);
截图
边栏推荐
- Dota2 Senate [greed and queue]
- Sentinel vs Hystrix 限流对比,到底怎么选?
- Leetcode-720: the longest word in a dictionary
- Stale Read 功能的使用场景
- Support millions of concurrent server tests
- Leetcode-307: region and retrieval - array modifiable
- 如果想和开发少battle,那你一定要懂数据库
- 寻找斐波那契数
- Auto. JS learning note 18: sub thread and timer are used together (an example is at the end)
- JUC no lock
猜你喜欢
Grey correlation analysis
In the software testing interview, the interviewer asks you some "difficult" questions. How will you answer them
JUC memory
Tidb high concurrency write scenario best practices
Machine learning - Integrated Learning
Pytorch(三)——FashionMNIST时装分类
MySQL grant之后一定要跟随flush privileges么?
【C】 General template of information management system / address book (introduce static, dynamic and file versions)
基于 ABP 实现 DDD-- 领域服务、应用服务和 DTO 实践
灰色关联分析
随机推荐
MySQL高级篇(C)
跳槽?面试软件测试需要掌握的7个技能Get了吗?
Microservice practice | centralized configuration center config symmetric encryption practice
寻找斐波那契数
Notes and Thoughts on the red dust of the curtain of Heaven (II) you know what others know and what you know
Talk about how programmers improve their writing ability
Apachecon Asia 2022 opens registration: pulsar technology issues make a big debut
JUC-同步
Database expansion can also be so smooth, MySQL 100 billion level data production environment expansion practice
Job hopping? Have you got the 7 skills you need to master in the interview software test?
JUC no lock
Support millions of concurrent server tests
Is it safe for Huatai Securities to open an account and open online banking? Do you need to go to the sales department
Idea decompiles the entire jar package source code
Best practices for monitoring tidb with grafana
易基因 | 简化基因组DNA甲基化测序(RRBS)实验怎么做?
社区活动 | Apache Doris 毕业庆典活动圆满结束!
2. Overview of information collection
Error: your local changes to the following files would be overwritten by merge:xxxx
Advanced architects, 16 common principles of microservice design and Governance