防采集标记:亢少军老师的课程和资料
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
title: 'Table表格布局示例',
home: new MyApp(),
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Table表格布局示例'),
),
body: new Center(
child: Table(
//设置表格有多少列,并且指定列宽
columnWidths: const {
0: FixedColumnWidth(100.0),
1: FixedColumnWidth(40.0),
2: FixedColumnWidth(80.0),
3: FixedColumnWidth(80.0),
},
//设置表格边框样式
border: TableBorder.all(color: Colors.black38, width: 2.0, style: BorderStyle.solid),
children: const [
//添加第一行数据
TableRow(
children: [
Text('姓名'),
Text('性别'),
Text('年龄'),
Text('身高'),
],
),
//添加第二行数据
TableRow(
children: [
Text('张三'),
Text('男'),
Text('26'),
Text('172'),
],
),
//添加第三行数据
TableRow(
children: [
Text('李四'),
Text('男'),
Text('28'),
Text('178'),
],
),
],
),
),
);
}
}
- Flutter技术入门与实战: http://product.dangdang.com/26485813.html
- Flutter交流学习群:894109159
- Flutter开源项目请关注: https://github.com/kangshaojun
- Flutter视频教程:https://edu.csdn.net/lecturer/2436
@作者: 亢少军