我想使用底部導航欄上的路線和 Navigator.pushNamed() 瀏覽頁面。在這里,我使用 FlashyTab 欄來美觀。更具體地說,按導航欄上的每個圖示應該會將我帶到不同的頁面,我想使用路由來實作這一點。
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
bottomNavigationBar: FlashyTabBar(
animationCurve: Curves.linear,
selectedIndex: _selectedIndex,
showElevation: true,
onItemSelected: (index) => setState(() {
_selectedIndex = index;
}),
items: [
FlashyTabBarItem(
icon: const Icon(Icons.account_box),
title: const Text('Challenger'),
),
FlashyTabBarItem(
icon: const Icon(Icons.phone),
title: const Text('Contact'),
),
FlashyTabBarItem(
icon: const Icon(Icons.dashboard_rounded),
title: const Text('Events'),
),
FlashyTabBarItem(
icon: const Icon(Icons.badge),
title: const Text('Quick Scan'),
),
],
),
body:
);
}
uj5u.com熱心網友回復:
在你的螢屏上定義這個
List<Widget> pageList = [
const ChallengerScreen(),
const ContactScreen(),
const EventsScreen(),
const QuickScanScreen(),
];
在身體上這樣使用
return Scaffold(
bottomNavigationBar: FlashyTabBar(
animationCurve: Curves.linear,
selectedIndex: _selectedIndex,
showElevation: true,
onItemSelected: (index) => setState(() {
_selectedIndex = index;
}),
items: [
FlashyTabBarItem(
icon: const Icon(Icons.account_box),
title: const Text('Challenger'),
),
FlashyTabBarItem(
icon: const Icon(Icons.phone),
title: const Text('Contact'),
),
FlashyTabBarItem(
icon: const Icon(Icons.dashboard_rounded),
title: const Text('Events'),
),
FlashyTabBarItem(
icon: const Icon(Icons.badge),
title: const Text('Quick Scan'),
),
],
),
//you have to just do changes here...
body:pageList.elementAt(_selectedIndex)
);
你不需要用Navigator.pushNamed()它不正確的方法去做。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/497935.html
上一篇:關閉鍵盤后文本欄位仍保持焦點?
