不对,我不是想让BottomNavigationBar位于CustomScrollView的底部,而是让它始终固定在屏幕的最下面
时间: 2024-05-01 17:24:12 浏览: 17
哦,我明白了,你想要的是让BottomNavigationBar在屏幕的底部固定位置,而不是在CustomScrollView的底部。那么你可以使用Scaffold组件来实现这一点。
在Scaffold组件中,有一个属性叫做bottomNavigationBar,它可以让你将底部导航栏放在屏幕的底部。你可以将你的BottomNavigationBar组件作为这个属性的值,如下所示:
```
Scaffold(
body: CustomScrollView(
// ...
),
bottomNavigationBar: BottomNavigationBar(
// ...
),
)
```
这样,BottomNavigationBar就会始终固定在屏幕的最下面了。希望这可以帮到你。
相关问题
bottomNavigationBar 显示在页面最外层
是的,bottomNavigationBar通常被放置在页面的最外层,位于屏幕底部,并提供导航选项卡供用户选择。它通常用于应用程序的主导航,例如在应用程序中浏览不同的页面或选项卡。bottomNavigationBar可以通过Flutter中的Scaffold Widget来实现。您可以在Scaffold的底部导航栏中设置bottomNavigationBar属性,以显示您的导航选项卡。
如何让showModalBottomSheet不覆盖bottomNavigationBar
要在Flutter中使用showModalBottomSheet而不覆盖bottomNavigationBar,您可以将它放在一个Scaffold中,并将其放在Scaffold的底部。这样,bottomNavigationBar将保持可见,并且showModalBottomSheet将显示在其上方。
以下是一个示例代码:
```dart
class MyPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My App'),
),
body: Center(
child: RaisedButton(
child: Text('Show Modal Bottom Sheet'),
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return Container(
height: 200,
child: Center(
child: Text('Modal Bottom Sheet'),
),
);
},
);
},
),
),
bottomNavigationBar: BottomNavigationBar(
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
title: Text('Settings'),
),
],
),
);
}
}
```
在这个示例中,我们在Scaffold的底部放置了bottomNavigationBar,并在中间添加了一个RaisedButton来触发showModalBottomSheet。当我们点击按钮时,showModalBottomSheet将显示在bottomNavigationBar的上方,而不是覆盖它。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)