Add SingleChildScrollView
for NavigationRail
(#137415)
## Description Add `SingleChildScrollView` to `NavigationRail` for scrolling. Closes: #89167
This commit is contained in:
parent
f727948f6d
commit
fd7f45a8be
@ -439,6 +439,7 @@ class _NavigationRailState extends State<NavigationRail> with TickerProviderStat
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment(0, groupAlignment),
|
alignment: Alignment(0, groupAlignment),
|
||||||
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -475,6 +476,7 @@ class _NavigationRailState extends State<NavigationRail> with TickerProviderStat
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -3605,6 +3605,62 @@ void main() {
|
|||||||
expect(inkFeatures, paints..circle(color: Colors.transparent));
|
expect(inkFeatures, paints..circle(color: Colors.transparent));
|
||||||
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
|
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
|
||||||
|
|
||||||
|
testWidgets('NavigationRail can scroll in low height', (WidgetTester tester) async {
|
||||||
|
// This is a regression test for https://github.com/flutter/flutter/issues/89167.
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
theme: ThemeData(
|
||||||
|
useMaterial3: true,
|
||||||
|
),
|
||||||
|
home: Builder(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return MediaQuery(
|
||||||
|
// Set Screen height with 300
|
||||||
|
data: MediaQuery.of(context).copyWith(size: const Size(800, 300)),
|
||||||
|
child: Scaffold(
|
||||||
|
body: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
// Set NavigationRail height with 100
|
||||||
|
SizedBox(
|
||||||
|
height: 100,
|
||||||
|
child: NavigationRail(
|
||||||
|
selectedIndex: 0,
|
||||||
|
destinations: const <NavigationRailDestination>[
|
||||||
|
NavigationRailDestination(
|
||||||
|
icon: Icon(Icons.favorite_border),
|
||||||
|
selectedIcon: Icon(Icons.favorite),
|
||||||
|
label: Text('Abc'),
|
||||||
|
),
|
||||||
|
NavigationRailDestination(
|
||||||
|
icon: Icon(Icons.bookmark_border),
|
||||||
|
selectedIcon: Icon(Icons.bookmark),
|
||||||
|
label: Text('Def'),
|
||||||
|
),
|
||||||
|
NavigationRailDestination(
|
||||||
|
icon: Icon(Icons.star_border),
|
||||||
|
selectedIcon: Icon(Icons.star),
|
||||||
|
label: Text('Ghi'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Expanded(
|
||||||
|
child: Text('body'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final ScrollableState scrollable = tester.state(find.byType(Scrollable));
|
||||||
|
scrollable.position.jumpTo(500.0);
|
||||||
|
expect(scrollable.position.pixels, equals(500.0));
|
||||||
|
});
|
||||||
|
|
||||||
group('Material 2', () {
|
group('Material 2', () {
|
||||||
// These tests are only relevant for Material 2. Once Material 2
|
// These tests are only relevant for Material 2. Once Material 2
|
||||||
// support is deprecated and the APIs are removed, these tests
|
// support is deprecated and the APIs are removed, these tests
|
||||||
@ -5433,10 +5489,11 @@ TestSemantics _expectedSemantics() {
|
|||||||
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
|
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
|
||||||
children: <TestSemantics>[
|
children: <TestSemantics>[
|
||||||
TestSemantics(
|
TestSemantics(
|
||||||
flags: <SemanticsFlag>[
|
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
|
||||||
SemanticsFlag.isSelected,
|
children: <TestSemantics>[
|
||||||
SemanticsFlag.isFocusable,
|
TestSemantics(
|
||||||
],
|
flags: <SemanticsFlag>[SemanticsFlag.isSelected,
|
||||||
|
SemanticsFlag.isFocusable],
|
||||||
actions: <SemanticsAction>[SemanticsAction.tap],
|
actions: <SemanticsAction>[SemanticsAction.tap],
|
||||||
label: 'Abc\nTab 1 of 4',
|
label: 'Abc\nTab 1 of 4',
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
@ -5459,6 +5516,8 @@ TestSemantics _expectedSemantics() {
|
|||||||
label: 'Jkl\nTab 4 of 4',
|
label: 'Jkl\nTab 4 of 4',
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
TestSemantics(
|
TestSemantics(
|
||||||
label: 'body',
|
label: 'body',
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user