5-flutter 布局和列表
布局和列表
类型 | 作用特点 |
---|---|
Container | 只有一个子 Widget。默认充满,包含了padding、margin、color、宽高、decoration 等配置。 |
Padding | 只有一个子 Widget。只用于设置Padding,常用于嵌套child,给child设置padding。 |
Center | 只有一个子 Widget。只用于居中显示,常用于嵌套child,给child设置居中。 |
Stack | 可以有多个子 Widget。 子Widget堆叠在一起。 |
Column | 可以有多个子 Widget。垂直布局。 |
Row | 可以有多个子 Widget。水平布局。 |
Expanded | 只有一个子 Widget。在 Column 和 Row 中充满。 |
ListView | 可以有多个子 Widget。自己意会吧。 |
1 container 的使用
new Container(///四周10大小的maringmargin: EdgeInsets.all(10.0),height: 120.0,width: 500.0,decoration: new BoxDecoration(///弧度为4.0borderRadius: BorderRadius.all(Radius.circular(4.0)),///设置了decoration的color,就不能设置Container的color。color: Colors.red,///边框border: new Border.all(color:Colors.blue, width: 5)),child:new Text("666666"))),
2 Row 横向 布局 和 Column 布局
主轴方向是 start 或 center 等;副轴方向方向是 start 或 center 等;mainAxisSize 是充满最大尺寸,或者只根据子 Widget 显示最小尺寸。
//主轴方向,Column的竖向、Row我的横向
mainAxisAlignment: MainAxisAlignment.start,
//默认是最大充满、还是根据child显示最小大小
mainAxisSize: MainAxisSize.max,
//副轴方向,Column的横向、Row我的竖向
crossAxisAlignment :CrossAxisAlignment.center,
_showItem(IconData icon,String text){// 充满Row 的横向布局return new Expanded(flex: 1,// 居中显示child: new Center(// 横向布局child: new Row(// 主轴居中mainAxisAlignment: MainAxisAlignment.center,// // 大小按照最大充满mainAxisSize: MainAxisSize.max,// // 竖向居中crossAxisAlignment: CrossAxisAlignment.center,children: <Widget>[//一个图标new Icon(icon,size:20,color:Colors.red),// 间隔new Padding(padding: new EdgeInsets.only(left:10)),// // 显示文本new Text(text,style:new TextStyle(color: Colors.black,fontSize: 20),// // // 超过的省略显示为省略号overflow: TextOverflow.ellipsis,// // // 最长1行maxLines: 1,),],),),);}
3 RelativeLayout 相对布局
用于使widget 相对于彼此位置排。
4 分层布局
Stack 控件将其子项相对于框的边缘定位。如果您只想重叠多个子窗口小部件,这个类很有用。
譬如说 图片上面添加一个标签
@overrideWidget build(BuildContext context) {return Stack(alignment: const Alignment(0.5, 0.5),children: <Widget>[CircleAvatar(backgroundImage: NetworkImage("http://img.redocn.com/sheying/20150213/mulanweichangcaoyuanfengjing_3951976.jpg"),), Container(decoration: BoxDecoration(color: Colors.red),child: Text("Ye Ge"),) ],);}
5 设置布局样式
用以下的方式进行布局
- padding
- center
- column
- row
6 LIstView 列表组件
scrollView 和 Tableview 的作用
更新列表方法 setState()
Flutter 渲染引擎会检查widget 树来查看widget 树 是否有什么地方改变了
动态的添加数据使用ListView.builder 来构建列表
class _MyCanvas extends StatelessWidget{@overrideWidget build(BuildContext context) {// 制作一些数据_makeSomeData(){// 创建一个存放widget的数组List<Widget> arr = [];for (int i =0;i < 100;i ++){arr.add(Padding(padding: EdgeInsets.all(20),child: Text("第 $i 行"),));} return arr;}// TODO: implement buildreturn Scaffold(appBar: AppBar(title: Text("Alex Code"),),body: Center(child: ListView(children: _makeSomeData()), ),);}
相关文章:

shell awk实战
一、文本处理 1、按行提取关键字频次(如取第5列) awk BEGIN{FS"|"} {a[$5]1;} END {for(i in a) print i ":" a[i];} OPT.ForumLogicNewServer_action_20161107.log | sort -nrk 2 -t : 2、日志用户每分钟访问量统计 这里我们统计日…

pix怎么抚养另一只猫_在工作和抚养两个孩子的同时,我如何在一年内获得第二学位并获得了5个开发人员认证...
pix怎么抚养另一只猫“The standard pace is for chumps. The system is designed so anyone can keep up. If you’re more driven than ‘just anyone’ — you can do so much more than anyone expects. And this applies to ALL of life — not just school.” — Derek S…

Wireshark网络抓包(三)——网络协议
一、ARP协议 ARP(Address Resolution Protocol)地址解析协议,将IP地址解析成MAC地址。 IP地址在OSI模型第三层,MAC地址在OSI第二层,彼此不直接通信; 在通过以太网发生IP数据包时,先封装第三层&a…

实现Java中的ArrayList
最近深受轮子哥影响,觉得造一些轮子应该会对自己的技术功底有一定的帮助,就决定先从简单的容器开始实现。废话不多说,就先实现一个Java中的ArrayList。 ArrayList是我们在Java中使用非常多的一个类,它是顺序表的数组实现ÿ…

6-flutter 状态管理
1 StatelessWidget 不需要状态改变的widget,它没有要管理的内部状态。 Text,CircleAvator 都是其子类 其传递的参数别final 修饰,不可变的 无状态的widget build 方法在以下三种情况下进行调用 当widget 插入到数中去当widget 父级更改配置的时候当…

大二上学数据结构和操作系统_毕业后的工作比上学要重要得多。 这是数据。...
大二上学数据结构和操作系统by Aline Lerner通过艾琳勒纳(Aline Lerner) 毕业后的工作比上学要重要得多。 这是数据。 (What you do after you graduate matters way more than where you went to school. Here’s the data.) The first blog post I published that got any r…

关于C#中编译器保证变量必须初始化规则猜想
现在两种情况: 第一种情况: using System; namespace Wrox {public class Program{static void Main(string[] args){int index; if(true){ index 100; } Console.WriteLine(index); Cons…

Bootstrap table表格
Bootstrap table 使用类 Class"table" 既可让table美化样式 table 相关的Class 隔行换色 : table-striped 鼠标悬停效果: table-hover 表格的边框 : table-bordered 垂直居中 : vertical-align 表头颜色:c…

flutter报错Could not connect to lockdownd, error code -
关于 flutter 报错信息解决方案 第一步: cmdshiftg 前往 /var/db 文件夹,找到lockdown文件夹,修改读写权限 第二步 : 打开命令行,依次执行 brew update brew uninstall --ignore-dependencies libimobiledevice brew uninstall…

k8s aws 部署_如何在短短30分钟内使用CircleCI设置到AWS S3的持续部署
k8s aws 部署by Adam Watt通过亚当瓦特 如何在短短30分钟内使用CircleCI设置到AWS S3的持续部署 (How to setup Continuous Deployment to AWS S3 using CircleCI in just 30 minutes) Continuous Deployment might seem complicated at first, but don’t be intimidated. In…

SharePoint 2010 单点登录
SharePoint2010单点登录 1.进入管理中心》应用程序管理 2.找到 Secure Store Service 应用程序代理 3.然后就是新建了 5.输入网站集管理员 6.这个时候SharePoint就知道你需要给OA这个系统做单点登录了。 7.下一步就是我们要把我们进OA系统的帐号密码告诉SharePoint,…
Java IO流学习总结三:缓冲流-BufferedInputStream、BufferedOutputStream
Java IO流学习总结三:缓冲流-BufferedInputStream、BufferedOutputStream 转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/54894451 本文出自【赵彦军的博客】 InputStream |__FilterInputStream|__BufferedInputStream 首先抛出一个…

7-flutter Navigator 和Route
Route 和 Navigator 用于页面之间的跳转 一 Navigator 的 push 和 pop 用于页面之间的跳转 创建MaterialApp时可以指定routes参数,该参数是一个映射路由名称和构造器的Map 跳转的时候 使用 push 跳回的时候使用 pop import package:flutter/cupertino.dart; im…

小规模网络数据公开数据_大规模的在线公开课程曾经是100%免费的。 但是他们没有那样做。...
小规模网络数据公开数据I took one of the first Massive Open Online Courses (MOOCs) in 2011. Back then, everything was 100% free: the videos, the assignments, and the certificates. But in 2017, you can’t find this sort of free learning experience anymore.我…

swift -charts框架雷达图
参考资料 import UIKit import Chartsclass ViewController: UIViewController {let activities ["力量", "敏捷", "生命", "智力", "魔法"]override func viewDidLoad() {super.viewDidLoad()// Do any additional setup…

vector容器总结.xml
1 清空所有元素m_itemVector.clear(); 2 遍历vector<ITEM_CHECK>::iterator iterm_itemVector.begin(); for(i0;iter!m_itemVector.end();iter,i) { if(iter->flag-1) { break; } iter->flag1; } vector<ITEM_CHECK>::iterator iterm_itemVector.b…

Syncthing源码解析 - 第三方库
1,AudriusButkevicius/cli 网址:https://github.com/AudriusButkevicius/cli 2,bkaradzic/go-lz4 网址:https://github.com/bkaradzic/go-lz4 3,calmh 备注:这位是Syncthing项目创立者和最主要的开发者&…

安全工程师2017年真题_以下是2017年全球软件工程师的平均薪水
安全工程师2017年真题And here are those same salaries adjusted to San Francisco’s cost of living:以下是根据旧金山的生活费用调整后的相同工资: As you can see, cost of living is an important consideration. Also, you don’t need to move to San Fran…

测试思想 什么是软件测试(摘录)
什么是软件测试(摘录) by:授客 QQ:1033553122 IEEE 标准的定义:使用人工或自动的手段来运行或测定某个系统的过程,其目的在于检验;它是否满足规定的需求或是弄清预期结果与实际结果之间的差别。对软件测试还有一些不同的定义。 G.J.Myers给出的定义:“程…

8-flutter 异步和线程
线程和异步的UI 1 异步的使用 Dart 有一个单线程执行模型,支持Isolate(一种在另外一种线程运行dart的方法),一个事件循环和异步编程。 可以使用async / await 来做网络请求不会挂起UI 使用http 导入 import ‘dart:io’; import ‘dart:c…

前端页面紫红色_谷歌正在开发一种神秘的新型移动操作系统,称为紫红色
前端页面紫红色Google seems to be building a replacement for Android called Fuchsia. Yesterday, they revealed what their new Armadillo user interface looks like (see photo above, courtesy of Ars Technica).谷歌似乎正在建立一个名为Fuchsia的 Android替代产品。 …

iOS UIButton 文字图片上下左右布局
例如文字在左 图片在右,iOS 9 之后一句话搞定 backBtn.semanticContentAttribute UISemanticContentAttributeForceRightToLeft;按钮标题居左实现 dateBtn.contentHorizontalAlignment UIControlContentHorizontalAlignmentLeft; dateBtn.contentEdgeInsets UIEdgeInsetsMak…

linux xampp eclipse xdebug 无法进入断点
一、xampp 版本 1.8.3-5 xampp安装后会自动集成xdebug,目录一般为 /opt/lampp/lib/php/extensions/***-debug-***目录 关于php 与php.ini路径 php程序路径为:/opt/lampp/bin/ php.ini配置文件路径为:/opt/lampp/etc/ 1、配置文件一般在/opt/lampp/etc/ph…

sliva数据库简介--转载
sliva rRNA数据库(http://www.arb-silva.de/)用来检查和比对RNA序列,既可以针对16S/18S,SSU,也可以针对23S/28S, LSU,包括了Bacteria, Archaea and Eukarya。同时也是ARB的官方指定数据库。 LSU: Large subunit (23S/2…

haproxy ssl_我们如何微调HAProxy以实现2,000,000个并发SSL连接
haproxy sslby Sachin Malhotra由Sachin Malhotra 我们如何微调HAProxy以实现2,000,000个并发SSL连接 (How we fine-tuned HAProxy to achieve 2,000,000 concurrent SSL connections) If you look at the above screenshot closely, you’ll find two important pieces of in…

OC文件操作(1)
1.文件的浅度遍历与深度遍历: //NSFileManager * fm [[NSFileManager alloc]init];//创建文件管理器 //第一步创建一个文件管理器 NSError * error nil; //显示路径下的内容,作用类似于ls -a指令 //返回值是把目录下的内容放到NSArray中 //浅度遍历 NSFileManager …

10-flutter 使用http包请求和网络指示器
使用http package 进行网络请求操作 1 安装步骤 Step1 在pubspec.yaml 文件中添加依赖 dependencies:http: ^0.12.01Step2 flutter packages getStep3 导入头文件 import ‘package:http/http.dart’ as http; 2 使用 var responseBody;http.Response response await http.…

使用nat方式解决虚拟机联网问题
本文全文参考:http://jingyan.baidu.com/album/4e5b3e1957979d91901e24f1.html?picindex1,谢谢 对于很多的linux初学者来说,最开始学习linux时通常是在虚拟机上进行的,然而对于新手来说虚拟机联网会对他们来说是比较困难的。…

老年痴呆 数字化_设计老年人愉快数字体验的5条原则
老年痴呆 数字化by Kaye Mao毛凯(Kaye Mao) 设计老年人愉快数字体验的5条原则 (5 Principles for Designing Delightful Digital Experiences for Seniors) When we got my grandfather his first smart phone, he was thrilled. He had heard all about the wonders of video…

hdu 3664 1~n排列(aii ) 为k个数
http://acm.hdu.edu.cn/showproblem.php?pid3664 求1~n的排列个数,使得逆序数(ai>i ) 为给定的k. dp[i][j]表示前1~i的排列中,有j个数是逆序数的个数. #include <cstdio> #include <cstdlib> #include <cmath> #includ…