mirror of
https://github.com/flutter/flutter
synced 2024-08-28 04:21:14 +00:00
Add splashColor property for ListTile widget (#100652)
This commit is contained in:
parent
a490a6a11d
commit
e0a83e6250
|
@ -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(
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue