Skip to content

Commit

Permalink
Fix ListTile theme shape in a drawer (#106343)
Browse files Browse the repository at this point in the history
  • Loading branch information
TahaTesser committed Jul 8, 2022
1 parent 255b71f commit 750516a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/drawer.dart
Expand Up @@ -683,7 +683,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
@override
Widget build(BuildContext context) {
assert(debugCheckHasMaterialLocalizations(context));
return ListTileTheme(
return ListTileTheme.merge(
style: ListTileStyle.drawer,
child: _buildDrawer(context),
);
Expand Down
33 changes: 33 additions & 0 deletions packages/flutter/test/material/list_tile_theme_test.dart
Expand Up @@ -444,4 +444,37 @@ void main() {

expect(find.byType(Material), paints..path(color: selectedTileColor));
});

testWidgets('ListTile uses ListTileTheme shape in a drawer', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/106303

final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final ShapeBorder shapeBorder = RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0));

await tester.pumpWidget(MaterialApp(
theme: ThemeData(
listTileTheme: ListTileThemeData(shape: shapeBorder),
),
home: Scaffold(
key: scaffoldKey,
drawer: const Drawer(
child: ListTile(),
),
body: Container(),
),
));
await tester.pumpAndSettle();

scaffoldKey.currentState!.openDrawer();
// Start drawer animation.
await tester.pump();

final ShapeBorder? inkWellBorder = tester.widget<InkWell>(
find.descendant(
of: find.byType(ListTile),
matching: find.byType(InkWell),
)).customBorder;
// Test shape.
expect(inkWellBorder, shapeBorder);
});
}

0 comments on commit 750516a

Please sign in to comment.