使用Flutter怎么實(shí)現(xiàn)一個(gè)底部菜單欄功能?針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
成都創(chuàng)新互聯(lián)公司從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站建設(shè)、成都網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元定陶做網(wǎng)站,已為上家服務(wù),為定陶各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18980820575import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget{ @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: MyHomePage(), ), ); } } class MyHomePage extends StatefulWidget{ MyHomePage({Key key}) : super(key:key); @override _MyHomePageState createState() => _MyHomePageState(); @override Widget build(BuildContext context) { // TODO: implement build return null; } } class _MyHomePageState extends State<MyHomePage> { int _selectedIndex = 1;//當(dāng)前選中項(xiàng)的索引 final _widgetOptions = [ Text('Index 0: 微信'), Text('Index 1: 通訊錄'), Text('Index 2: 發(fā)現(xiàn)'), Text('Index 3:我') ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('仿微信'), ), body: Center( child: _widgetOptions.elementAt(_selectedIndex),//居中顯示某個(gè)文本 ), //底部導(dǎo)航按鈕,包含圖標(biāo)及文本 bottomNavigationBar: BottomNavigationBar( items: <BottomNavigationBarItem>[ BottomNavigationBarItem(icon: Icon(Icons.chat),backgroundColor:Colors.green,title: Text('微信')),//設(shè)置背景顏色和icon的描述 BottomNavigationBarItem(icon: Icon(Icons.contacts),backgroundColor:Colors.green,title: Text('通訊錄')), BottomNavigationBarItem(icon: Icon(Icons.account_circle),backgroundColor:Colors.green,title: Text('發(fā)現(xiàn)')), BottomNavigationBarItem(icon: Icon(Icons.memory),backgroundColor:Colors.green,title: Text('我')), ], // backgroundColor: Colors.green, currentIndex: _selectedIndex,//當(dāng)前選中項(xiàng)的索引 fixedColor: Colors.deepPurple,//選項(xiàng)中項(xiàng)的顏色 onTap:_onItemTapped,//選擇按下處理 ), ); } //選擇按下處理 void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } }
關(guān)于使用Flutter怎么實(shí)現(xiàn)一個(gè)底部菜單欄功能問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
名稱欄目:使用Flutter怎么實(shí)現(xiàn)一個(gè)底部菜單欄功能-創(chuàng)新互聯(lián)
地址分享:http://muchs.cn/article42/cdsiec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、Google、定制網(wǎng)站、搜索引擎優(yōu)化、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容