如何使Bottommodalsheet从底部绘制栏弹出
我对Flutter相对较新,我想知道如何从Navigationbar出现Bottommodalsheet。我目前正在使用[persistent_bottom_nav_bar]( 1 这是我的我在做什么的代码
PersistentTabController _controller = PersistentTabController(initialIndex: 0);
class MyNavBar extends StatelessWidget {
const MyNavBar({Key? key}) : super(key: key);
Widget build(BuildContext context) {
return PersistentTabView(
context,
controller: _controller,
screens: _buildScreens(),
items: _navBarsItems(),
confineInSafeArea: true,
backgroundColor: Colors.transparent,
handleAndroidBackButtonPress: true,
resizeToAvoidBottomInset: true,
stateManagement: true,
hideNavigationBarWhenKeyboardShows: true,
decoration: NavBarDecoration(
borderRadius: BorderRadius.circular(10.0),
colorBehindNavBar: Colors.transparent,
),
popAllScreensOnTapOfSelectedTab: true,
popActionScreens: PopActionScreensType.all,
itemAnimationProperties: ItemAnimationProperties(
duration: Duration(milliseconds: 200),
curve: Curves.ease,
),
screenTransitionAnimation: ScreenTransitionAnimation(
animateTabTransition: true,
curve: Curves.ease,
duration: Duration(milliseconds: 200),
),
navBarStyle: NavBarStyle.style6,
);
}
}
List<Widget> _buildScreens() {
return [
Container(
child: Text("Page one"),
),
Container(child: Text("Page one")), //place holder
Container(child: Text('Modal Sheet')),/// <====== NEED THIS TO MAKE A bottom MODAL SHEET POP UP WHEN SELECTED ON THE NAV BAR
Container(child: Text("Page 3")), //place holder text
Container(child: Text("Page 4")) //place holder text
];
}
List<PersistentBottomNavBarItem> _navBarsItems() {
return [
PersistentBottomNavBarItem(
icon: Icon(CupertinoIcons.home),
title: ("First"),
activeColorPrimary: CupertinoColors.activeBlue,
inactiveColorPrimary: CupertinoColors.systemGrey,
),
PersistentBottomNavBarItem(
icon: Icon(CupertinoIcons.settings),
title: ("Second"),
activeColorPrimary: CupertinoColors.activeBlue,
inactiveColorPrimary: CupertinoColors.systemGrey,
),
PersistentBottomNavBarItem(
icon: Icon(CupertinoIcons.car_detailed),
title: ("Add"),
activeColorPrimary: CupertinoColors.activeBlue,
inactiveColorPrimary: CupertinoColors.systemGrey,
),
PersistentBottomNavBarItem(
icon: Icon(CupertinoIcons.bell),
title: ("Second"),
activeColorPrimary: CupertinoColors.activeBlue,
inactiveColorPrimary: CupertinoColors.systemGrey,
),
PersistentBottomNavBarItem(
icon: Icon(CupertinoIcons.circle_grid_hex_fill),
title: ("Last"),
activeColorPrimary: CupertinoColors.activeBlue,
inactiveColorPrimary: CupertinoColors.systemGrey,
),
];
}`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一个函数,可为您提供ModalBottomSheet,然后在任何需要的地方调用它。例如,我通过用手势检测器将所有PersistentTabView包裹起来来称呼它;
You can create a function that provides you to a modalbottomsheet and then call it wherever you want. For example I called it by wrapping all PersistentTabView with gesture detector, Here;