Repository navigation
Making NavigationRail scrollable #89167
Description
Use case
By default, when a NavigationRailDestination inside a NavigationRail goes out of the viewport (e.g. the window is resized to be less than the destinations), it will overflow and cause the infamous yellow-and-black-striped error to occur. One way to fix this is to make the NavigationRail itself scrollable. Currently, the only way to do this is rather janky.
Error-causing:
Row(
children: [
NavigationRail(...),
...
]
)The "fix" that makes it scrollable:
Row(
children: [
LayoutBuilder(
builder: (context, constraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
),
child: IntrinsicHeight(
child: NavigationRail(...)
)
)
);
}
),
...
]
)This fix is mentioned in this StackOverflow answer and is also used by Flutter Gallery. However, it is janky and cluttered. It even uses an IntrinsicHeight wherein the docs explicitly state that:
In the class constructor:
This class is relatively expensive. Avoid using it where possible.
In the class itself:
This class is relatively expensive, because it adds a speculative layout pass before the final layout phase. Avoid using it where possible. In the worst case, this widget can result in a layout that is O(N²) in the depth of the tree.
I want to avoid using widgets that the docs itself says not to use. However, I cannot find any other way to make it scrollable to avoid the infamous yellow-and-black-striped error.
Proposal
I propose a simple solution to this problem:
Row(
children: [
NavigationRail(
scrollable: true,
...
),
...
]
)Not only does this makes things easier and intuitive, but is also easily customizable and less clutter.
Activity
TahaTesser commentedon Aug 31, 2021
Hi @yivanscreations
Thanks for filing the proposals.
minimal code sample
maheshj01 commentedon Aug 31, 2021
Assigning this issue to myself will send a PR tonight
DaedalusDelta commentedon Feb 23, 2023
Hi, I'm also a web-developer. Just wondering if the proposed scrollable feature would be added any time soon.
4 remaining items
adonisRodxander commentedon Feb 27, 2025
flutter-triage-bot commentedon Feb 27, 2025
This issue is missing a priority label. Please set a priority label when adding the
triaged-designlabel.pogojotz commentedon Jun 2, 2025
Hi. I recently added a PR for this issue. After some research into the previously merged and reverted PR #137415, I decided to reuse it with the "scrollable" feature being optional, so that existing code will not break. Users have to opt-in, by setting the flag.
The PR adds two further flags,
leadingAtTopandtrailingAtBottom. For a justification, see my comment in the PR.NavigationRail: optionally scrollable and more configurable (#169421)
github-actions commentedon Jul 11, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.NavigationRail: optionally scrollable and more configurable (flutter#…
NavigationRail: optionally scrollable and more configurable (flutter#…