FirestoreDataTable constructor

const FirestoreDataTable({
  1. Key? key,
  2. required Query<Object?> query,
  3. required Map<String, Widget> columnLabels,
  4. Widget? header,
  5. void onError(
    1. Object error,
    2. StackTrace stackTrace
    )?,
  6. bool canDeleteItems = true,
  7. List<Widget>? actions,
  8. int? sortColumnIndex,
  9. bool sortAscending = true,
  10. @Deprecated('Migrate to use dataRowMinHeight and dataRowMaxHeight instead. ' 'This feature was deprecated after v3.7.0-5.0.pre.') double? dataRowHeight,
  11. double? dataRowMinHeight,
  12. double? dataRowMaxHeight,
  13. double headingRowHeight = 56.0,
  14. double horizontalMargin = 24.0,
  15. double columnSpacing = 56.0,
  16. bool showCheckboxColumn = true,
  17. bool showFirstLastButtons = false,
  18. void onPageChanged(
    1. int page
    )?,
  19. int rowsPerPage = 10,
  20. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  21. Color? arrowHeadColor,
  22. double? checkboxHorizontalMargin,
  23. CellBuilder? cellBuilder,
  24. bool enableDefaultCellEditor = true,
  25. OnTapCell? onTapCell,
  26. OnSelectedRows? onSelectedRows,
})

A PaginatedDataTable that is connected to Firestore.

The parameter columnLabels is required and is used to

  • list the columns.
  • give them a label.
  • order the columns.
  • let FirestoreDataTable know what are the expected keys in a Firestore document.

An example usage would be:

// A collection of {'name': string, 'age': number}
final usersCollection = FirebaseFirestore.instance.collection('users');

// ...

FirestoreDataTable(
  query: usersCollection,
  columnLabels: {
     'name': Text('User name'),
     'age': Text('age'),
  },
);

Implementation

const FirestoreDataTable({
  super.key,
  required this.query,
  required this.columnLabels,
  this.header,
  this.onError,
  this.canDeleteItems = true,
  this.actions,
  this.sortColumnIndex,
  this.sortAscending = true,
  @Deprecated(
    'Migrate to use dataRowMinHeight and dataRowMaxHeight instead. '
    'This feature was deprecated after v3.7.0-5.0.pre.',
  )
  double? dataRowHeight,
  double? dataRowMinHeight,
  double? dataRowMaxHeight,
  this.headingRowHeight = 56.0,
  this.horizontalMargin = 24.0,
  this.columnSpacing = 56.0,
  this.showCheckboxColumn = true,
  this.showFirstLastButtons = false,
  this.onPageChanged,
  this.rowsPerPage = 10,
  this.dragStartBehavior = DragStartBehavior.start,
  this.arrowHeadColor,
  this.checkboxHorizontalMargin,
  this.cellBuilder,
  this.enableDefaultCellEditor = true,
  this.onTapCell,
  this.onSelectedRows,
})  : assert(
        columnLabels is LinkedHashMap,
        'only LinkedHashMap are supported as header',
      ),
      dataRowMinHeight =
          dataRowHeight ?? dataRowMinHeight ?? kMinInteractiveDimension,
      dataRowMaxHeight =
          dataRowHeight ?? dataRowMaxHeight ?? kMinInteractiveDimension;