網站首頁 編程語言 正文
正文
這是一個和時間一樣古老的故事。您的應用程序有三到五個主要內容區域,您的用戶應該能夠在任何屏幕之間切換。
那么,在這種情況下,請查看NavigationBar。
現在,您可能會想,“底部們有導航欄嗎?,這個新的導航欄小部件有什么特別之處?“
不同之處在于BoottomNavigationBar使用Material 2設計系統,而NavigationBar具有新的Material 3外觀和感覺。
例如,藥丸形狀,它以對比色指示活動的目的地。
要啟動并運行,為NavigationBar提供destination列表,當前所選的索引以及每當選擇destination時出發的回調而已。
NavigationBar(
destinations: [
NavigationDestination(
icon: Icon(Icons.home),
label: 'Home',
),
NavigationDestination(
icon: Icon(Icons.explore),
label: 'Explore',
),
NavigationDestination(
icon: Icon(Icons.person),
label: 'Profile',
),
NavigationDesstination(
icon: Icon(Icons.settings_rounded,
label: 'Settings',
),
],
selectedIndex: currentPageIndex,
onDestinationSelected: (int index) {
setState(() {
currentPageIndex = index;
});
}
)
現在您的應用程序可以使用選定的索引來決定要承鉉哪個視圖。
Scaffold(
bottomNavigationBar: NavigationBar(...),
body: [Widget1, Widget2, Widget3, Widget4][currentPageIndex]
)
您可以使用它并配置諸如labelBehavior
NavigationBar(
destinations: [...].
selectedIndex: currentPageIndex,
onDestinationSelected: (int index) {...},
labelBehavior: onlyShowSelected,
)
background
NavigationBar(
destinations: [...],
selectedIndex: currentPageIndex,
onDestinationSelected: (int index) {...},
backgroundColor: Colors.grey,
)
和animationDuration之類的東西,以便當destination在選中和未選中之間更改狀態時。
NavigationBar(
destinations: [...],
selectedIndex: currentPageIndex,
onDestinationSelected: (int index) {...},
animationDuration: Duration(ms: 1000),
)
準備好在大屏幕訪問您的應用程序了嗎?將NavigationBar與NaviigationRail欄配對,您將立即擁有一個完全相應的導航系統。
如果想了解有關NavigationBar的內容,或者關于Flutter的其他功能,請訪問?flutter.dev
原文鏈接:https://juejin.cn/post/7174262771289161741
相關推薦
- 2022-10-10 react通過組件拆分實現購物車界面詳解_React
- 2023-03-28 Go實現set類型的示例代碼_Golang
- 2022-03-14 Failed to load ApplicationContext
- 2022-06-10 解決Qt設置QTextEdit行高的問題_C 語言
- 2022-05-07 Python中的集合一起來學習一下_python
- 2023-07-22 垃圾回收的核心知識點解析
- 2023-02-25 C和C++如何實現互相調用詳解_C 語言
- 2022-06-10 ASP.NET?Core使用AutoMapper組件_實用技巧
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支