main.dart
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
theme: ThemeData(primarySwatch: Colors.blueGrey),
home: Scaffold(
appBar: AppBar(
title: const Text("Flutter - Table Column Width")
),
body: bodyContent()
),
),
);
}
bodyContent(){
return Table(
defaultColumnWidth: const FixedColumnWidth(100),
children: [
TableRow(children: [
getBox(Colors.indigo),getBox(),getBox()
]),
TableRow(children: [
getBox(Colors.blue),getBox(Colors.green.shade300),getBox()
]),
TableRow(children: [
getBox(Colors.yellow),getBox(),getBox(Colors.yellow.shade200)
]),
TableRow(children: [
getBox(Colors.pink.shade100),getBox(Colors.purple),getBox()
])
]
);
}
getBox([Color color = Colors.black12]){
return Container(
height: 50,
color: color,margin: const EdgeInsets.all(8)
);
}
More flutter tutorials
- flutter – Function multiple parameters
- flutter – How to create custom function
- flutter – Table column different width
- flutter – Table intrinsic column width
- flutter – Table border radius
- flutter – Table outside border
- flutter – Table inside border
- flutter – Table vertical inside border
- flutter – Table border only bottom
- flutter – Table row background color
- flutter – How to use FractionallySizedBox
- flutter – How to use SizedBox
- flutter – SizedBox background color
- flutter – BoxDecoration border only
- flutter – BoxDecoration gradient