flutter - 将尾随小部件推送到 Flutter Navigation Rail 的底部
问题描述
如何将 Flutter Navigation Rail 中的尾随小部件推到导轨底部?我认为这就像用 Expanded 小部件包装尾随小部件一样简单,但我得到了通常的颤动“需要油漆”错误消息。
如果我添加一个具有固定高度的 SizedBox 的第一个子项的 Column,然后添加我想要显示的小部件,我可以让它工作,但我需要“间隔器”来填充可用空间,而不是固定高度。这是 SizedBox 示例,它确实填充了 200px 的空间,但我如何让它填充可用空间?
// other navrail properties....
trailing: Column(
children: [
SizedBox(
height: 200,
),
IconButton(icon: Icon(Icons.settings), onPressed: () {})
],
),
解决方案
I found a solution (or workaround):
Put the NavigationRail
and an Positioned
widget in a Stack
:
Scaffold(
body: Row(
children: [
Stack(
children: [
NavigationRail(
selectedIndex: _selectedIndex,
extended: Styling.isLargeScreen(context),
destinations: _destinations
.map((d) => d.toNavigationDestination)
.toList(),
onDestinationSelected: (index) => _onItemTapped(index),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
color: Colors.amber,
height: 100,
),
)
],
),
Expanded(
child: _buildPage(_destinations.elementAt(_selectedIndex).key),
),
],
),
);
Hopefully it gets fixed soon!
推荐阅读
- python - 我该如何解决这个问题?追溯:文件“C:/Users/rawaa/PycharmProjects/huffman/deempade.py”,第 56 行,seed=pickle.load(fp) EOFError
- javascript - 如何通过对象名称动态检索对象属性?
- c++ - Clang-Format:多行语句后在换行符上打开大括号
- loopback - Loopback 4:调试 SQL 语句
- assembly - 汇编语言 addw vs addw vs
- c - 计算C中链表中的冗余
- puppeteer - 使用 puppeteer login gmail get 无法登录
- javascript - PWA,Service Worker 错误:“Internet 连接似乎处于脱机状态”
- regex - 如何使用正则表达式捕获包含一个或多个任意单词的多个组
- docker - Dockerfile RUN 命令损坏。我如何正确逃避它?