From 9dec4fbd1e3c81fddcf0c6b32a793264a6823613 Mon Sep 17 00:00:00 2001 From: Rydmike Date: Thu, 23 Mar 2023 20:13:47 +0200 Subject: [PATCH] FIX: NavigationDrawer hover/focus/pressed does not use indicatorShape (#123325) FIX: NavigationDrawer hover/focus/pressed do not use indicatorShape --- .../flutter/lib/src/material/navigation_drawer.dart | 2 +- .../flutter/test/material/navigation_drawer_test.dart | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/navigation_drawer.dart b/packages/flutter/lib/src/material/navigation_drawer.dart index 3b89a7ed47..24d3f2fc75 100644 --- a/packages/flutter/lib/src/material/navigation_drawer.dart +++ b/packages/flutter/lib/src/material/navigation_drawer.dart @@ -328,7 +328,7 @@ class _NavigationDestinationBuilder extends StatelessWidget { child: InkWell( highlightColor: Colors.transparent, onTap: info.onTap, - borderRadius: const BorderRadius.all(Radius.circular(28.0)), + customBorder: info.indicatorShape ?? navigationDrawerTheme.indicatorShape ?? defaults.indicatorShape!, child: Stack( alignment: Alignment.center, children: [ diff --git a/packages/flutter/test/material/navigation_drawer_test.dart b/packages/flutter/test/material/navigation_drawer_test.dart index db614bda08..722915cc60 100644 --- a/packages/flutter/test/material/navigation_drawer_test.dart +++ b/packages/flutter/test/material/navigation_drawer_test.dart @@ -349,12 +349,16 @@ void main() { // Test default indicator color and shape. expect(_getIndicatorDecoration(tester)?.color, theme.colorScheme.secondaryContainer); expect(_getIndicatorDecoration(tester)?.shape, const StadiumBorder()); + // Test that InkWell for hover, focus and pressed use default shape. + expect(_getInkWell(tester)?.customBorder, const StadiumBorder()); await tester.pumpWidget(buildNavigationDrawer(indicatorColor: color, indicatorShape: shape)); // Test custom indicator color and shape. expect(_getIndicatorDecoration(tester)?.color, color); expect(_getIndicatorDecoration(tester)?.shape, shape); + // Test that InkWell for hover, focus and pressed use custom shape. + expect(_getInkWell(tester)?.customBorder, shape); }); } @@ -376,6 +380,13 @@ Material _getMaterial(WidgetTester tester) { ); } +InkWell? _getInkWell(WidgetTester tester) { + return tester.firstWidget( + find.descendant( + of: find.byType(NavigationDrawer), matching: find.byType(InkWell)), + ); +} + ShapeDecoration? _getIndicatorDecoration(WidgetTester tester) { return tester .firstWidget(