Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit 32d9aa0

Browse files
Googlernshahan
authored andcommitted
Having selected color input override the default color value in a 'selectable scoreboard'.
PiperOrigin-RevId: 175973688
1 parent 7519629 commit 32d9aa0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/scorecard/scoreboard.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class ScoreboardComponent implements OnInit, OnDestroy {
250250
if (type == ScoreboardType.selectable) {
251251
int i = 0;
252252
for (ScorecardComponent scorecard in _scorecards) {
253-
scorecard.selectedColor = chartingPalette[i % chartingPalette.length];
253+
scorecard.selectedColor ??= chartingPalette[i % chartingPalette.length];
254254
i++;
255255
}
256256
}

lib/scorecard/scorecard.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class ScorecardComponent extends KeyboardOnlyFocusIndicatorDirective {
202202

203203
/// The [Color] to apply to the scorecard background when it is selected.
204204
@Input()
205-
Color selectedColor = chartingPalette[0];
205+
Color selectedColor;
206206

207207
/// Fired when the selection state changes.
208208
@Output()
@@ -212,7 +212,9 @@ class ScorecardComponent extends KeyboardOnlyFocusIndicatorDirective {
212212
///
213213
/// A [selected] and [selectable] scorecard uses [selectedColor].
214214
@HostBinding('style.background')
215-
String get backgroundStyle => selected ? selectedColor.hexString : 'inherit';
215+
String get backgroundStyle => selected
216+
? selectedColor?.hexString ?? chartingPalette[0].hexString
217+
: 'inherit';
216218

217219
@HostListener('click')
218220
void handleClick() {

0 commit comments

Comments
 (0)