FirebaseDatabaseDataTable constructor

const FirebaseDatabaseDataTable({
  1. Key? key,
  2. required Query 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. double dataRowHeight = kMinInteractiveDimension,
  11. double headingRowHeight = 56.0,
  12. double horizontalMargin = 24.0,
  13. double columnSpacing = 56.0,
  14. bool showCheckboxColumn = true,
  15. bool showFirstLastButtons = false,
  16. void onPageChanged(
    1. int page
    )?,
  17. int rowsPerPage = 10,
  18. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  19. Color? arrowHeadColor,
  20. double? checkboxHorizontalMargin,
})

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 FirebaseDatabaseDataTable know what are the expected keys in a Firestore document.

An example usage would be:

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

// ...

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

Implementation

const FirebaseDatabaseDataTable({
  Key? key,
  required this.query,
  required this.columnLabels,
  this.header,
  this.onError,
  this.canDeleteItems = true,
  this.actions,
  this.sortColumnIndex,
  this.sortAscending = true,
  this.dataRowHeight = kMinInteractiveDimension,
  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,
})  : assert(
        columnLabels is LinkedHashMap,
        'only LinkedHashMap are supported as header',
      ), // using an assert instead of a type because `<A, B>{}` types as `Map` but is an instance of `LinkedHashMap`
      super(key: key);