Data Table

Loading preview

Starting the Flutter app

A showcase of Flutter's data table functionality

Get the source

Add it to your project

Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.

First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.

How it works

Flutter’s built-in DataTable renders _users, a copy of five hardcoded _rows, against an inline columns list. Two nested SingleChildScrollViews, one horizontal and one vertical, keep wide or long tables reachable. Delete opens a dialog through _confirmDelete and removes the row from _users only once confirmed. Edit shows a demo SnackBar, and there is no sorting, selection or paging.

Adapting it

  • Swap _rows for a fetched list of a typed class, which removes the as String casts in every DataCell.
  • Replace _showDemo with your edit dialog, and call your API from _confirmDelete.
  • Move to PaginatedDataTable for big datasets, since DataTable builds every row up front.