apptomate_custom_data_table 0.0.2

SDKflutter
Platformandroidioswindowslinuxmacosweb

An enhanced DataTable widget with customizable styling and layout options for Flutter applications.

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

PropertyTypeDescriptionDefault
columnsList<DataColumn>Required table columns-
rowsList<DataRow>Required table rows-
showCheckboxColumnboolShow selection checkbox columnfalse
headingRowColorColor?Header row background colorTheme-based
evenRowColorColor?Even row background colorTheme-based
oddRowColorColor?Odd row background colorTheme-based
columnSpacingdoubleSpace between columns12.0
dataRowMinHeightdoubleMinimum row height48.0
dataRowMaxHeightdoubleMaximum row heightdouble.infinity
headingRowHeightdoubleHeader row height56.0
horizontalMargindoubleHorizontal margin12.0
verticalMargindoubleVertical margin8.0
sortableboolEnable column sortingtrue
paginatedboolEnable paginationfalse
rowsPerPageintRows per page when paginated5
showActionsboolShow action buttonsfalse
actionsList<Widget>?Custom action widgetsnull
borderTableBorder?Table border styleDefault border
headingTextStyleTextStyle?Header text styleTheme-based
rowTextStyleTextStyle?Row text styleTheme-based
showFirstLastButtonsboolShow first/last page buttonsfalse
showTooltipboolShow column tooltipstrue
resizableColumnsboolAllow column resizingfalse
scrollableboolEnable scrollingtrue
physicsScrollPhysics?Scroll physicsPlatform default
showFooterboolShow item count footerfalse

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)