Skip to content

Commit

Permalink
CellStyle.background not being used in null-valued cells. #29
Browse files Browse the repository at this point in the history
  • Loading branch information
caduandrade committed May 27, 2022
1 parent caf2e20 commit b85a054
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.5.2

* Bugfix
* `CellStyle.background` not being used in null-valued cells.

## 1.5.1

* Bugfix
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.5.0"
version: "1.5.1"
fake_async:
dependency: transitive
description:
Expand Down
58 changes: 30 additions & 28 deletions lib/src/internal/table_row_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,41 +72,43 @@ class TableRowPainter<ROW> 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,
Expand All @@ -118,7 +120,7 @@ class TableRowPainter<ROW> extends CustomPainter {
alignment: alignment,
padding: padding,
textPainter: textPainter);
} else if (nullValueColor != null) {
} else if (nullValueColor != null && background == null) {
_paintBackground(
left: left,
right: right,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/theme/cell_theme_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b85a054

Please sign in to comment.