CustomDataTable for Flutter

A highly customizable DataTable widget for Flutter applications with additional features like pagination, sorting, and styling options.

Features

  • Customizable styling: Control colors, borders, and text styles for different parts of the table
  • Pagination support: Built-in pagination controls with configurable rows per page
  • Sorting: Optional column sorting functionality
  • Responsive design: Horizontal and vertical scrolling for small screens
  • Checkbox column: Optional selection column
  • Action buttons: Add custom actions above the table
  • Dark mode support: Automatic adaptation to theme brightness
  • Resizable columns: Optional column resizing
  • Tooltips: Optional tooltips for column headers

Installation

Add the dependency to your pubspec.yaml:

dependencies:
  apptomate_custom_data_table: ^0.0.2

Usage

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

class MyTablePage extends StatelessWidget {
  final List<DataRow> sampleRows = [
    // Your data rows here
  ];
  
  final List<DataColumn> sampleColumns = [
    // Your columns here
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomDataTable(
        columns: sampleColumns,
        rows: sampleRows,
        paginated: true,
        rowsPerPage: 10,
        showActions: true,
        actions: [
          IconButton(
            icon: Icon(Icons.add),
            onPressed: () {/* Add action */},
          ),
        ],
      ),
    );
  }
}

Properties

Property Type Description Default
columns List<DataColumn> Required table columns -
rows List<DataRow> Required table rows -
showCheckboxColumn bool Show selection checkbox column false
headingRowColor Color? Header row background color Theme-based
evenRowColor Color? Even row background color Theme-based
oddRowColor Color? Odd row background color Theme-based
columnSpacing double Space between columns 12.0
dataRowMinHeight double Minimum row height 48.0
dataRowMaxHeight double Maximum row height double.infinity
headingRowHeight double Header row height 56.0
horizontalMargin double Horizontal margin 12.0
verticalMargin double Vertical margin 8.0
sortable bool Enable column sorting true
paginated bool Enable pagination false
rowsPerPage int Rows per page when paginated 5
showActions bool Show action buttons false
actions List<Widget>? Custom action widgets null
border TableBorder? Table border style Default border
headingTextStyle TextStyle? Header text style Theme-based
rowTextStyle TextStyle? Row text style Theme-based
showFirstLastButtons bool Show first/last page buttons false
showTooltip bool Show column tooltips true
resizableColumns bool Allow column resizing false
scrollable bool Enable scrolling true
physics ScrollPhysics? Scroll physics Platform default
showFooter bool Show item count footer false

Customization

The widget automatically adapts to your app's theme (light/dark mode) but you can override any colors or styles as needed.

Example

See the example above in the Usage section for a basic implementation. For more advanced usage, you can:

  • Add sorting callbacks to your DataColumns
  • Implement custom actions
  • Style different parts of the table independently
  • Combine with other widgets in your layout

Limitations

  • Column resizing (resizableColumns) is not fully implemented in the current version
  • Very large datasets may impact performance (consider implementing data virtualization for huge datasets)