Datatable example in flutter

This Article is posted by seven.srikanth at 10/29/2021 6:40:27 AM



Here is an example of Datatable in flutter.
Here is the complete code from main.dart file. 

import 'package:flutter/material.dart';
main(List<String> args) {
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @ override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: MyDataTable(),
      ),
    );
  }
}
class MyDataTable extends StatefulWidget {
  const MyDataTable({Key? key}) : super(key: key);
  @ override
  State<MyDataTable> createState() => _MyDataTableState();
}
class _MyDataTableState extends State<MyDataTable> {
  @ override
  Widget build(BuildContext context) {
    return Center(
        child: DataTable(
      columns: const [
        DataColumn(label: Text('RollNo')),
        DataColumn(label: Text('Name'))
      ],
      rows: const [
        DataRow(cells: [DataCell(Text('1')), DataCell(Text('Rama'))]),
        DataRow(cells: [DataCell(Text('2')), DataCell(Text('Lakshmana'))]),
        DataRow(cells: [DataCell(Text('3')), DataCell(Text('Sita'))])
      ],
    ));
  }
}
Thanks,
Srikanth

Tags:








0 Comments
Login to comment.
Recent Comments












© 2018 - Fluttercentral | Email to me - seven.srikanth@gmail.com