main.dart
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
theme: ThemeData(primarySwatch: Colors.blueGrey),
home: Scaffold(
appBar: AppBar(
title: const Text("Flutter - How to use Table")
),
body: bodyContent()
),
),
);
}
bodyContent(){
return Table(
children: [
TableRow(children: [
getBox(Colors.amber),getBox(),getBox()
]),
TableRow(children: [
getBox(Colors.blue),getBox(Colors.green),getBox()
]),
TableRow(children: [
getBox(Colors.yellow),getBox(),getBox(Colors.indigo)
]),
TableRow(children: [
getBox(Colors.green.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 – ListTile remove padding
- flutter – Space between ListTile leading and title
- flutter – ListTile background color
- flutter – ListTile shape
- flutter – ListTile separator
- flutter – Random number in range
- flutter – Random double in range
- flutter – Double 2 decimal
- flutter – How to generate random color
- flutter – Get random element from a list
- flutter – How to generate random string
- flutter – How to generate random bool
- flutter – How to use Google Fonts
- flutter – Google fonts text theme
- flutter – Function default value