Unverified Commit 21de8505 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Fix NavigationRail Indicator alignment for `NavigationRailLabelType.none` (#98028)

parent ef803a2b
......@@ -579,12 +579,14 @@ class _RailDestination extends StatelessWidget {
final Widget iconPart = SizedBox(
width: minWidth,
height: minWidth,
child: _AddIndicator(
addIndicator: useIndicator,
indicatorColor: indicatorColor,
isCircular: true,
indicatorAnimation: destinationAnimation,
child: themedIcon,
child: Center(
child: _AddIndicator(
addIndicator: useIndicator,
indicatorColor: indicatorColor,
isCircular: true,
indicatorAnimation: destinationAnimation,
child: themedIcon,
),
),
);
if (extendedTransitionAnimation.value == 0) {
......
......@@ -2349,6 +2349,50 @@ void main() {
expect(indicator.width, 56);
expect(indicator.height, 32);
});
testWidgets('NavigationRailDestination has center aligned indicator - [labelType]=none', (WidgetTester tester) async {
// This is a regression test for
// https://github.com/flutter/flutter/issues/97753
await _pumpNavigationRail(
tester,
navigationRail: NavigationRail(
labelType: NavigationRailLabelType.none,
selectedIndex: 0,
destinations: <NavigationRailDestination>[
NavigationRailDestination(
icon: Stack(
children: const <Widget>[
Icon(Icons.umbrella),
Positioned(
top: 0,
right: 0,
child: Text(
'Text',
style: TextStyle(fontSize: 10, color: Colors.red),
),
),
],
),
label: const Text('Abc'),
),
const NavigationRailDestination(
icon: Icon(Icons.umbrella),
label: Text('Def'),
),
const NavigationRailDestination(
icon: Icon(Icons.bookmark_border),
label: Text('Ghi'),
),
],
),
);
// Indicator with Stack widget
final RenderBox firstIndicator = tester.renderObject(find.byType(Icon).first);
expect(firstIndicator.localToGlobal(Offset.zero).dx, 24.0);
// Indicator without Stack widget
final RenderBox lastIndicator = tester.renderObject(find.byType(Icon).last);
expect(lastIndicator.localToGlobal(Offset.zero).dx, 24.0);
});
}
TestSemantics _expectedSemantics() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment