Json Table Widget
This Flutter package provides a Json Table Widget for directly showing table from a json(Map). Supports Column toggle also.
Installation
In the
dependencies:
section of your pubspec.yaml
, add the following line:Usage
Import this class
Add Json Table Widget
- Accepts Map
as input. Just decode your json array string and pass it in JsonTable. No casting to model required. - Option for creating column header builder. This basically returns a widget to show as table column header
- Option for creating table cell builder
- Option for toggling column(s) also. User can customise which columns are to be shown
- Vanilla Implementation
- Implementation with HEADER and CELL widget builders
Head over to example code: simple_table.dart
- Implementation with custom COLUMNS list
- Pass custom column list to control what columns are displayed in table
- The list item must be constructed using JsonTableColumn class
- JsonTableColumn provides 4 parameters, namely,
- First parameter is the field/key to pick from the data
- label: The column header label to be displayed
- defaultValue: To be used when data or key is null
- valueBuilder: To get the formatted value like date etc.
Head over to example code: custom_column_table.dart
Key Highlights
- The table constructed isn't the flutter's native DataTable.
- The table is manually coded hence serves a great learning purpose on how to create simple tables manually in flutter
- Supports vertical & horizontal scroll
- Supports custom columns includes default value, column name, value builder
TODO
- [X] Custom header list parameter. This will help to show only those keys as mentioned in header list
- [X] Add support for keys missing in json object
- [X] Add support for auto formatting of date
- [X] Extracting column headers logic must be change. Not to depend on first object
- [ ] Pagination support etc. Its good if this table can be replaced with Flutter's native DataTable
- [ ] Add option to change header row to vertical row on left