dateColumn<T extends Object> method

TableColumn<T> dateColumn<T extends Object>({
  1. required String title,
  2. required DateTime? value(
    1. T
    ),
  3. String pattern = 'dd/MM/yyyy',
  4. double sizeFactor = .1,
  5. bool sortable = false,
  6. String? id,
  7. bool isMain = false,
})

Date column rendered with DateFormat using pattern.

When value returns null the cell shows an em-dash placeholder.

Implementation

TableColumn<T> dateColumn<T extends Object>({
  required String title,
  required DateTime? Function(T) value,
  String pattern = 'dd/MM/yyyy',
  double sizeFactor = .1,
  bool sortable = false,
  String? id,
  bool isMain = false,
}) {
  final formatter = DateFormat(pattern);
  return TableColumn<T>(
    id: id,
    title: Text(title),
    cellBuilder: (item) {
      final d = value(item);
      return Text(d == null ? '—' : formatter.format(d));
    },
    sizeFactor: sizeFactor,
    sortable: sortable,
    isMain: isMain,
  );
}