Flutter Tutorials

Flutter app development tutorials


flutter – Table outside border

main.dart


import 'dart:math';
import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      theme: ThemeData(primarySwatch: Colors.pink),
      home: Scaffold(
          appBar: AppBar(
              title: const Text("Flutter - Table Outside Border")
          ),
          body: bodyContent()
      ),
    ),
  );
}

bodyContent(){
  return Padding(
    padding: const EdgeInsets.all(16),
    child: Table(
        border: TableBorder.symmetric(
          outside: BorderSide(
            color: Colors.green.shade300,
            width: 2,
            style: BorderStyle.solid,
          ),
        ),
        children: [
          TableRow(children: [getBox(),getBox(),getBox()]),
          TableRow(children: [getBox(),getBox(),getBox()]),
          TableRow(children: [getBox(),getBox(),getBox()]),
          TableRow(children: [getBox(),getBox(),getBox()]),
          TableRow(children: [getBox(),getBox(),getBox()])
        ]
    ),
  );
}

getBox(){
  Color color = Colors.primaries[
  Random().nextInt(Colors.primaries.length)
  ].shade200;
  return Container(
      height: 75, width: double.infinity,
      color: color,margin: const EdgeInsets.all(8)
  );
}

More flutter tutorials



About Me

Flutter Developer

Design a site like this with WordPress.com
Get started