Flutter:弹性布局组件:Expanded
简介Expanded组件是flutter中使用率很高的一个组件,它可以动态调整child组件沿主轴的尺寸,比如填充剩余空间,比如设置尺寸比例。它常常和Row或Column组合起来使用。
还记得在使用Row和Column组件的时候,我们内部的内容都聚集在一起的的吗?如果要让他们占满一行或一列进行平均分配或比例分配就需要Expanded组件。
Expanded有一个flex属性比较常用。flex表示弹性系数,默认是1。
1、将一行的内容进行比例分配
import 'package:flutter/material.dart';
class LayoutExpandedWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('弹性布局组件:Expanded'),
elevation: 0.0,
centerTitle: true,
),
body: Column(
children: [
Text("等比分配"),
Row(
children: [
Expanded(
child: Text("Row Text Left"),
),
Expanded(
child: Icon(Icons.add),
),
Expanded(
child: Text("Row Text Right"),
),
],
),
Row(
children: [
Expanded(
child: Container(
height: 150,
child: Text("Row Text Left"),
color: Colors.red,
),
),
Expanded(
child: Container(
height: 150,
child: Icon(Icons.add),
color: Colors.blue,
),
),
Expanded(
child: Container(
height: 150,
child: Text("Row Text Right"),
color: Colors.yellow,
),
)
],
),
Text("指定比例分配,需要设置flex:2:1:5"),
Row(
children: [
Expanded(
flex: 2,
child: Container(
height: 150,
child: Text("Row Text Left"),
color: Colors.red,
),
),
Expanded(
flex: 1,
child: Container(
height: 150,
child: Icon(Icons.add),
color: Colors.blue,
),
),
Expanded(
flex: 5,
child: Container(
height: 150,
child: Text("Row Text Right"),
color: Colors.yellow,
),
)
],
),
],
));
}
}
2、将一列的内容进行比例分配
import 'package:flutter/material.dart';
class LayoutExpandedWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('弹性布局组件:Expanded'),
elevation: 0.0,
centerTitle: true,
),
body: Row(
children: [
Column(
children: [
Expanded(
child: Text("Row Text Left"),
),
Expanded(
child: Icon(Icons.add),
),
Expanded(
child: Text("Row Text Right"),
),
],
),
Column(
children: [
Expanded(
child: Container(
height: 150,
child: Text("Row Text Left"),
color: Colors.red,
),
),
Expanded(
child: Container(
height: 150,
child: Icon(Icons.add),
color: Colors.blue,
),
),
Expanded(
child: Container(
height: 150,
child: Text("Row Text Right"),
color: Colors.yellow,
),
)
],
),
Column(
children: [
Expanded(
flex: 2,
child: Container(
height: 150,
child: Text("Row Text Left"),
color: Colors.red,
),
),
Expanded(
flex: 1,
child: Container(
height: 150,
child: Icon(Icons.add),
color: Colors.blue,
),
),
Expanded(
flex: 5,
child: Container(
height: 150,
child: Text("Row Text Right"),
color: Colors.yellow,
),
)
],
),
],
),
);
}
}

《康熙王朝》是一部非常优秀的电视连续剧,陈道明演的康熙是我觉得最有帝王气魄,让人意犹未尽,本文主要记录一小段非常经典的对白。
iotop命令是一款实时监控磁盘I/O的工具,必须要root用户才能运行。使用iotop可以和方便的查看每个进程使用磁盘I/O的情况。如果系统中没有iotop命令,就需要额外安装。
OpenOffice.org 是一套跨平台的办公室软件套件,能在Windows、Linux、MacOS X (X11)和 Solaris 等操作系统上执行。它与各个主要的办公室软件套件兼容。OpenOffice.org 是免费软件,任何人都可以免费下载、使用及推广它。
正则表达式通常被用来检索、替换那些符合某个模式(规则)的文本。工作中往往需要用到正则表达式,那么本文主要记录正则表达式的一些基本的知识和常用的正则表达式。
在做搜索列表分页的时候,需要分页后的页面跳转的url地址中包含搜索的参数,在Laravel中的如何处理呢?
快速生成表格
Electron页面跳转、浏览器打开链接和打开新窗口
在使用Git的过程中,不想每次都输入用户名和密码去拉取代码,所以就需要保存这些信息,那么既然有保存了,就必须有清除功能。
在Mac电脑中,如何对Git的用户名和密码进行修改呢?起初不懂Mac,所以整了很久,本文将记录如何对这个进行操作,以便后期使用。
Docker编译镜像出现:fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.12/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory问题