Brian Kayfitz
Committed by GitHub

Add helper functions to replace text styles and cell content

... ... @@ -24,6 +24,10 @@ import 'text_style.dart';
import 'theme.dart';
import 'widget.dart';
typedef OnCell = Widget? Function(int index, dynamic data, int rowNum);
typedef OnCellTextStyle = TextStyle? Function(
int index, dynamic data, int rowNum);
mixin TableHelper {
static TextAlign _textAlign(Alignment align) {
if (align.x == 0) {
... ... @@ -71,6 +75,8 @@ mixin TableHelper {
BoxDecoration? oddRowDecoration,
TextDirection? headerDirection,
TextDirection? tableDirection,
OnCell? cellBuilder,
OnCellTextStyle? textStyleBuilder,
}) {
assert(headerCount >= 0);
... ... @@ -161,14 +167,17 @@ mixin TableHelper {
: cellDecoration(tableRow.length, cell, rowNum),
child: cell is Widget
? cell
: Text(
cellFormat == null
? cell.toString()
: cellFormat(tableRow.length, cell),
style: isOdd ? oddCellStyle : cellStyle,
textAlign: _textAlign(align.resolve(textDirection)),
textDirection: tableDirection,
),
: cellBuilder?.call(tableRow.length, cell, rowNum) ??
Text(
cellFormat == null
? cell.toString()
: cellFormat(tableRow.length, cell),
style: textStyleBuilder?.call(
tableRow.length, cell, rowNum) ??
(isOdd ? oddCellStyle : cellStyle),
textAlign: _textAlign(align.resolve(textDirection)),
textDirection: tableDirection,
),
),
);
}
... ...