Add splashColor property for ListTile widget (#100652)

This commit is contained in:
Mohammed CHAHBOUN 2022-08-31 22:23:30 +01:00 committed by GitHub
parent a490a6a11d
commit e0a83e6250
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View file

@ -286,6 +286,7 @@ class ListTile extends StatelessWidget {
this.selected = false,
this.focusColor,
this.hoverColor,
this.splashColor,
this.focusNode,
this.autofocus = false,
this.tileColor,
@ -495,6 +496,9 @@ class ListTile extends StatelessWidget {
/// The color for the tile's [Material] when a pointer is hovering over it.
final Color? hoverColor;
/// The color of splash for the tile's [Material].
final Color? splashColor;
/// {@macro flutter.widgets.Focus.focusNode}
final FocusNode? focusNode;
@ -733,6 +737,7 @@ class ListTile extends StatelessWidget {
focusNode: focusNode,
focusColor: focusColor,
hoverColor: hoverColor,
splashColor: splashColor,
autofocus: autofocus,
enableFeedback: enableFeedback ?? tileTheme.enableFeedback ?? true,
child: Semantics(

View file

@ -1258,6 +1258,30 @@ void main() {
);
});
testWidgets('ListTile can be splashed and has correct splash color', (WidgetTester tester) async {
final Widget buildApp = MaterialApp(
home: Material(
child: Center(
child: SizedBox(
width: 100,
height: 100,
child: ListTile(
onTap: () {},
splashColor: const Color(0xff88ff88),
),
),
),
),
);
await tester.pumpWidget(buildApp);
await tester.pumpAndSettle();
final TestGesture gesture = await tester.startGesture(tester.getRect(find.byType(ListTile)).center);
await tester.pump(const Duration(milliseconds: 200));
expect(find.byType(Material), paints..circle(x: 50, y: 50, color: const Color(0xff88ff88)));
await gesture.up();
});
testWidgets('ListTile can be triggered by keyboard shortcuts', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const Key tileKey = Key('ListTile');