Flutter Tutorials

Flutter app development tutorials


flutter – Table column width

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



About Me

Flutter Developer

Design a site like this with WordPress.com
Get started