本文實例為大家分享了Flutter實現(xiàn)底部導航的具體代碼,供大家參考,具體內(nèi)容如下
岳池網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),岳池網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為岳池成百上千提供企業(yè)網(wǎng)站建設(shè)服務。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)公司要多少錢,請找那個售后服務好的岳池做網(wǎng)站的公司定做!BottomNavigationBar使用
底部導航欄 主文件 main.dart (注意導入文件路徑)
import 'package:flutter/material.dart'; import './views/firstPage.dart'; import './views/secondPage.dart'; import './views/thirdPage.dart'; //首先導入三個界面 void main() { runApp(new MyApp()); } class MyApp extends StatefulWidget { @override _MyHomePageState createState() => new _MyHomePageState(); } class _MyHomePageState extends State<MyApp> with TickerProviderStateMixin{ int _tabIndex = 0; List<BottomNavigationBarItem> _navigationViews; var appBarTitles = ['首頁', '發(fā)現(xiàn)', '我的']; PageController pageController; var _body; initData() { _body = new IndexedStack( children: <Widget>[new FirstPage(), new SecondPage(), new ThirdPage()], index: _tabIndex, ); } @override void initState() { super.initState(); _navigationViews = <BottomNavigationBarItem>[ new BottomNavigationBarItem( icon: const Icon(Icons.home), title: new Text(appBarTitles[0]), backgroundColor: Colors.blue, ), new BottomNavigationBarItem( icon: const Icon(Icons.widgets), title: new Text(appBarTitles[1]), backgroundColor: Colors.blue, ), new BottomNavigationBarItem( icon: const Icon(Icons.person), title: new Text(appBarTitles[2]), backgroundColor: Colors.blue, ), ]; } final navigatorKey = GlobalKey<NavigatorState>(); @override Widget build(BuildContext context) { initData(); return new MaterialApp( navigatorKey: navigatorKey, theme: new ThemeData( primaryColor: Colors.blue, accentColor: Colors.blue ), home: new Scaffold( appBar: new AppBar( title: new Text( appBarTitles[_tabIndex], style: new TextStyle(color: Colors.white), ), ), body: _body, bottomNavigationBar: new BottomNavigationBar( items: _navigationViews .map((BottomNavigationBarItem navigationView) => navigationView) .toList(), currentIndex: _tabIndex, type: BottomNavigationBarType.fixed, onTap: (index) { setState(() { _tabIndex = index; }); }, ), ), ); } }
當前文章:Flutter實現(xiàn)底部導航-創(chuàng)新互聯(lián)
當前路徑:http://bm7419.com/article42/dssohc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機、網(wǎng)頁設(shè)計公司、網(wǎng)站收錄、云服務器、Google、企業(yè)網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容