【发布时间】:2021-09-21 20:56:37
【问题描述】:
我需要这样的抽屉-> https://i.stack.imgur.com/TWT4H.jpg
这是我当前的代码。我正在使用persistent_bottom_nav_bar。我需要从底部导航栏最后一项触发抽屉。有人知道吗?如果无法从底部导航访问抽屉,是否有其他方法可以复制该 UI。谢谢
class BottomNav extends StatefulWidget {
const BottomNav({Key? key}) : super(key: key);
@override
_BottomNavState createState() => _BottomNavState();
}
class _BottomNavState extends State<BottomNav> {
late PersistentTabController _controller;
@override
void initState() {
super.initState();
_controller = PersistentTabController(initialIndex: 0);
setState(() {});
}
List<Widget> _buildScreens() {
return [
HomePage(),
HistoryPage(),
ServicePage(),
ProfilePage(),
];
}
List<PersistentBottomNavBarItem> _navBarsItems() {
return [
PersistentBottomNavBarItem(
icon: Icon(Icons.home),
title: ("Home"),
textStyle: TextStyle(fontWeight: FontWeight.w700, fontSize: 10),
activeColorPrimary: themeBlue,
inactiveColorPrimary: greyColor,
),
PersistentBottomNavBarItem(
icon: Icon(Icons.history),
title: ("History"),
activeColorPrimary: themeBlue,
textStyle: TextStyle(fontWeight: FontWeight.w700, fontSize: 10),
inactiveColorPrimary: greyColor,
),
PersistentBottomNavBarItem(
icon: Icon(Icons.apps_outlined),
title: ("Services"),
activeColorPrimary: themeBlue,
textStyle: TextStyle(fontWeight: FontWeight.w700, fontSize: 10),
inactiveColorPrimary: greyColor,
),
PersistentBottomNavBarItem(
icon: Icon(CupertinoIcons.person_alt_circle),
title: ("Profile"),
activeColorPrimary: themeBlue,
inactiveColorPrimary: greyColor,
textStyle: TextStyle(fontWeight: FontWeight.w700, fontSize: 10),
),
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: PersistentTabView(
context,
controller: _controller,
screens: _buildScreens(),
items: _navBarsItems(),
confineInSafeArea: true,
backgroundColor: Colors.white,
handleAndroidBackButtonPress: true,
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, // Choose the nav bar style with this property.
),
);
}
}
【问题讨论】:
-
@Hamed,是的。谢谢你的帮助
-
查看How to Ask 来改进这个问题。
标签: flutter