最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Flutter?Widget之NavigationBar使用詳解

 更新時間:2022年12月07日 16:42:50   作者:程序員界的小學(xué)生  
這篇文章主要為大家介紹了Flutter?Widget之NavigationBar使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

正文

這是一個和時間一樣古老的故事。您的應(yīng)用程序有三到五個主要內(nèi)容區(qū)域,您的用戶應(yīng)該能夠在任何屏幕之間切換。

那么,在這種情況下,請查看NavigationBar。

現(xiàn)在,您可能會想,“底部們有導(dǎo)航欄嗎?,這個新的導(dǎo)航欄小部件有什么特別之處?“

不同之處在于BoottomNavigationBar使用Material 2設(shè)計系統(tǒng),而NavigationBar具有新的Material 3外觀和感覺。

例如,藥丸形狀,它以對比色指示活動的目的地。

要啟動并運行,為NavigationBar提供destination列表,當(dāng)前所選的索引以及每當(dāng)選擇destination時出發(fā)的回調(diào)而已。

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;
        });
    }
)

現(xiàn)在您的應(yīng)用程序可以使用選定的索引來決定要承鉉哪個視圖。

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之類的東西,以便當(dāng)destination在選中和未選中之間更改狀態(tài)時。

NavigationBar(
    destinations: [...],
    selectedIndex: currentPageIndex,
    onDestinationSelected: (int index) {...},
    animationDuration: Duration(ms: 1000),
)

準備好在大屏幕訪問您的應(yīng)用程序了嗎?將NavigationBar與NaviigationRail欄配對,您將立即擁有一個完全相應(yīng)的導(dǎo)航系統(tǒng)。

如果想了解有關(guān)NavigationBar的內(nèi)容,或者關(guān)于Flutter的其他功能,請訪問 flutter.dev

以上就是Flutter Widget之NavigationBar使用詳解的詳細內(nèi)容,更多關(guān)于Flutter Widget NavigationBar的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論

青阳县| 贵德县| 晋州市| 修武县| 嘉黎县| 青海省| 嫩江县| 上饶县| 罗定市| 体育| 扶绥县| 清新县| 灵台县| 丹江口市| 中阳县| 额济纳旗| 洪泽县| 辛集市| 达孜县| 西平县| 邻水| 邵东县| 三穗县| 建昌县| 临潭县| 任丘市| 红原县| 海门市| 芷江| 蓬溪县| 齐齐哈尔市| 昌乐县| 本溪| 大厂| 白水县| 祁门县| 镇沅| 浠水县| 尼木县| 新巴尔虎左旗| 全南县|