[英]Swipe back gesture with BottomNavBar in Flutter
我正在使用底部導航欄,我需要推送帶有底部導航欄的視圖才能持久。
這是主頁:
MaterialApp(
theme: ThemeData(
pageTransitionsTheme: PageTransitionsTheme(builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
})),
home: Scaffold(
body: IndexedStack(
index: _pageIndex,
children: const <Widget>[
HomeView(),
VideosSectionsView(),
FavoritesView()
],
),
bottomNavigationBar: Column(
mainAxisSize: MainAxisSize.min,
children: [
showBottomPlayer ? bottomPlayer(context) : Row(),
const SizedBox(height: 0),
bottomNavigationBar()
],
)));
問題是,當我將一個視圖從 HomeView 推送到 SecondView,然后再次推送到 ThirdView 時,ThirdView 的向后滑動手勢(在屏幕的左邊緣)將我送回 HomeView,但我希望它將我送回 SecondView (所以只彈出一個視圖,而不是所有的堆棧)你知道實現這個嗎?
為此,我使用 CupertinoPageRoute:
Navigator.of(context, rootNavigator: false).push(
CupertinoPageRoute<bool>(
fullscreenDialog: false,
builder: (BuildContext context) => SecondView()
)
);
這很奇怪,因為如果我將“ rootNavigator ”設置為 true,它可以正常工作,我只能彈出堆棧的最后一個視圖,但底部導航欄不再保留在導航中!
所以我必須在良好的向后滑動手勢或持久的導航欄之間做出選擇......
以編程方式返回沒有問題:
Navigator.of(context).pop(true);
所以我想用滑動手勢做同樣的事情,謝謝大家
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.