第7章页面布局-FractionallySizedBox百分比布局
防采集标记:亢少军老师的课程和资料
import 'package:flutter/material.dart';
class LayoutDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('FractionallySizedBox百分比布局示例'),
),
body: new Container(
color: Colors.blueGrey,
height: 200.0,
width: 200.0,
child: new FractionallySizedBox(
alignment: Alignment.topLeft,//元素左上角对齐
widthFactor: 0.5,//宽度因子
heightFactor: 1.5,//高度因子
child: new Container(
color: Colors.green,
),
),
),
);
}
}
void main() {
runApp(
new MaterialApp(
title: 'FractionallySizedBox百分比布局示例',
home: new LayoutDemo(),
),
);
}
- Flutter技术入门与实战: http://product.dangdang.com/26485813.html
- Flutter交流学习群:894109159
- Flutter开源项目请关注: https://github.com/kangshaojun
- Flutter****:https://edu.****.net/lecturer/2436
@作者: 亢少军