diff --git a/CHANGELOG.md b/CHANGELOG.md index 1833821..7e5ea7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.5.2 + +* Bugfix + * `CellStyle.background` not being used in null-valued cells. + ## 1.5.1 * Bugfix diff --git a/example/pubspec.lock b/example/pubspec.lock index cf00733..2045360 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -63,7 +63,7 @@ packages: path: ".." relative: true source: path - version: "1.5.0" + version: "1.5.1" fake_async: dependency: transitive description: diff --git a/lib/src/internal/table_row_painter.dart b/lib/src/internal/table_row_painter.dart index c7c5d9f..e6cad95 100644 --- a/lib/src/internal/table_row_painter.dart +++ b/lib/src/internal/table_row_painter.dart @@ -72,41 +72,43 @@ class TableRowPainter extends CustomPainter { color: cellIcon.color))); } } else { - String? value = _stringValue(column: column); - if (value != null) { - CellStyle? cellStyle; - if (column.cellStyleBuilder != null) { - cellStyle = column.cellStyleBuilder!(row); + CellStyle? cellStyle; + if (column.cellStyleBuilder != null) { + cellStyle = column.cellStyleBuilder!(row); + } + if (cellStyle != null) { + if (cellStyle.alignment != null) { + alignment = cellStyle.alignment!; + } + if (cellStyle.textStyle != null) { + textStyle = cellStyle.textStyle; + } + if (cellStyle.background != null) { + background = cellStyle.background; } - if (cellStyle != null) { - if (cellStyle.alignment != null) { - alignment = cellStyle.alignment!; - } - if (cellStyle.textStyle != null) { - textStyle = cellStyle.textStyle; - } - if (cellStyle.background != null) { - background = cellStyle.background; - } - if (cellStyle.padding != null) { - padding = cellStyle.padding; - } + if (cellStyle.padding != null) { + padding = cellStyle.padding; } + } + + String? value = _stringValue(column: column); + if (value != null) { textPainter = _defaultTextPainter ..text = TextSpan(text: value, style: textStyle); } } + if (background != null) { + _paintBackground( + left: left, + right: right, + top: top, + bottom: bottom, + canvas: canvas, + color: background); + } + if (textPainter != null) { - if (background != null) { - _paintBackground( - left: left, - right: right, - top: top, - bottom: bottom, - canvas: canvas, - color: background); - } _paintTextPainter( left: left, right: right, @@ -118,7 +120,7 @@ class TableRowPainter extends CustomPainter { alignment: alignment, padding: padding, textPainter: textPainter); - } else if (nullValueColor != null) { + } else if (nullValueColor != null && background == null) { _paintBackground( left: left, right: right, diff --git a/lib/src/theme/cell_theme_data.dart b/lib/src/theme/cell_theme_data.dart index 6849897..75ca335 100644 --- a/lib/src/theme/cell_theme_data.dart +++ b/lib/src/theme/cell_theme_data.dart @@ -20,6 +20,8 @@ class CellThemeData { final Alignment alignment; + /// Defines a background when the cell value is null. + /// It is ignoring when [CellStyle.background] is not null. final EasyTableRowColor? nullValueColor; @override