Expose the tileColor property (#67135)
This commit is contained in:
@@ -262,6 +262,7 @@ class CheckboxListTile extends StatelessWidget {
|
||||
required this.onChanged,
|
||||
this.activeColor,
|
||||
this.checkColor,
|
||||
this.tileColor,
|
||||
this.title,
|
||||
this.subtitle,
|
||||
this.isThreeLine = false,
|
||||
@@ -320,6 +321,9 @@ class CheckboxListTile extends StatelessWidget {
|
||||
/// Defaults to Color(0xFFFFFFFF).
|
||||
final Color? checkColor;
|
||||
|
||||
/// {@macro flutter.material.ListTile.tileColor}
|
||||
final Color? tileColor;
|
||||
|
||||
/// The primary content of the list tile.
|
||||
///
|
||||
/// Typically a [Text] widget.
|
||||
@@ -438,6 +442,7 @@ class CheckboxListTile extends StatelessWidget {
|
||||
autofocus: autofocus,
|
||||
contentPadding: contentPadding,
|
||||
shape: shape,
|
||||
tileColor: tileColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -888,10 +888,12 @@ class ListTile extends StatelessWidget {
|
||||
/// {@macro flutter.widgets.Focus.autofocus}
|
||||
final bool autofocus;
|
||||
|
||||
/// {@template flutter.material.ListTile.tileColor}
|
||||
/// Defines the background color of `ListTile` when [selected] is false.
|
||||
///
|
||||
/// When the value is null, the `tileColor` is set to [ListTileTheme.tileColor]
|
||||
/// if it's not null and to [Colors.transparent] if it's null.
|
||||
/// {@endtemplate}
|
||||
final Color? tileColor;
|
||||
|
||||
/// Defines the background color of `ListTile` when [selected] is true.
|
||||
|
||||
@@ -258,6 +258,7 @@ class SwitchListTile extends StatelessWidget {
|
||||
Key? key,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
this.tileColor,
|
||||
this.activeColor,
|
||||
this.activeTrackColor,
|
||||
this.inactiveThumbColor,
|
||||
@@ -294,6 +295,7 @@ class SwitchListTile extends StatelessWidget {
|
||||
Key? key,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
this.tileColor,
|
||||
this.activeColor,
|
||||
this.activeTrackColor,
|
||||
this.inactiveThumbColor,
|
||||
@@ -374,6 +376,9 @@ class SwitchListTile extends StatelessWidget {
|
||||
/// Ignored if created with [SwitchListTile.adaptive].
|
||||
final Color? inactiveTrackColor;
|
||||
|
||||
/// {@macro flutter.material.ListTile.tileColor}
|
||||
final Color? tileColor;
|
||||
|
||||
/// An image to use on the thumb of this switch when the switch is on.
|
||||
final ImageProvider? activeThumbImage;
|
||||
|
||||
@@ -503,6 +508,7 @@ class SwitchListTile extends StatelessWidget {
|
||||
selected: selected,
|
||||
autofocus: autofocus,
|
||||
shape: shape,
|
||||
tileColor: tileColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -239,4 +239,24 @@ void main() {
|
||||
|
||||
expect(tester.widget<InkWell>(find.byType(InkWell)).customBorder, shapeBorder);
|
||||
});
|
||||
|
||||
testWidgets('CheckboxListTile respects tileColor', (WidgetTester tester) async {
|
||||
const Color tileColor = Colors.black;
|
||||
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
child: const Center(
|
||||
child: CheckboxListTile(
|
||||
value: false,
|
||||
onChanged: null,
|
||||
title: Text('Title'),
|
||||
tileColor: tileColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final ColoredBox coloredBox = tester.firstWidget(find.byType(ColoredBox));
|
||||
expect(coloredBox.color, equals(tileColor));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -357,4 +357,24 @@ void main() {
|
||||
|
||||
expect(tester.widget<InkWell>(find.byType(InkWell)).customBorder, shapeBorder);
|
||||
});
|
||||
|
||||
testWidgets('SwitchListTile respects tileColor', (WidgetTester tester) async {
|
||||
const Color tileColor = Colors.red;
|
||||
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
child: const Center(
|
||||
child: SwitchListTile(
|
||||
value: false,
|
||||
onChanged: null,
|
||||
title: Text('Title'),
|
||||
tileColor: tileColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final ColoredBox coloredBox = tester.firstWidget(find.byType(ColoredBox));
|
||||
expect(coloredBox.color, tileColor);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user