Flutter Table Widget | RRTutors

Flutter Table Widget

A widget that uses the table layout algorithm for its children

The height of each row of the table is determined by its content, and the width of each column is controlled individually by the columnWidths property
 

class TableWidget extends StatelessWidget{

 @override

 Widget build(BuildContext context) {

   // TODO: implement build

   return Scaffold(

     appBar: AppBar(title: Text("Table Widget"),backgroundColor: Colors.pink,),

     body: Container(

       child: Padding(

         padding: const EdgeInsets.all(8.0),

         child: Card(

           child: Table(

             columnWidths: const <int, TableColumnWidth>{

               0: FixedColumnWidth(50.0),

               1: FixedColumnWidth(100.0),

               2: FixedColumnWidth(50.0),

               3: FixedColumnWidth(100.0),

             },

 

             border: TableBorder.all(color: Colors.pink, width: 1.0, style: BorderStyle.solid),

             children: const <TableRow>[

 

               TableRow(

                 children: <Widget>[

                   Center(child: Text('A1',style: TextStyle(fontSize: 18),)),

                   Center(child: Text('B1',style: TextStyle(fontSize: 18),)),

                   Center(child: Text('C1',style: TextStyle(fontSize: 18),)),

                   Center(child: Text('D1',style: TextStyle(fontSize: 18),)),

                 ],

               ),

               TableRow(

                 children: <Widget>[

                   Center(child: Text('A2',style: TextStyle(fontSize: 18),)),

                   Center(child: Text('B2',style: TextStyle(fontSize: 18),)),

                   Center(child: Text('C2',style: TextStyle(fontSize: 18),)),

                   Center(child: Text('D2',style: TextStyle(fontSize: 18),)),

                 ],

               ),

               TableRow(

                 children: <Widget>[

                   Center(child: Text('A3',style: TextStyle(fontSize: 18),)),

                   Center(child: Text('B3',style: TextStyle(fontSize: 18),)),

                   Center(child: Text('C3',style: TextStyle(fontSize: 18),)),

                   Center(child: Text('D3',style: TextStyle(fontSize: 18),)),

                 ],

               ),

             ],

           ),

         ),

       )

       ,

     ),

   );

 }

 

}

 

Table Widget

Advertisements