這篇文章將為大家詳細(xì)講解有關(guān)使用Flutter怎么實(shí)現(xiàn)底部導(dǎo)航欄效果,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。
創(chuàng)新互聯(lián)主要從事成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)南陽,十載網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18980820575一.在main.dart文件中
定義APP的基本信息
class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter Demo', theme: new ThemeData( primarySwatch: themeColor(), ), home: new MyHomePage(title: 'Flutter Demo Home Page'), ); } }
其中主要代碼部分
class _MyHomePageState extends State<MyHomePage> { PageController pageController; int page = 0; @override Widget build(BuildContext context) { return new Scaffold( backgroundColor: Colors.grey, body: new PageView( children: [ new Index(), new Classify(), new Shopping(), new Myself() ], controller: pageController, onPageChanged: onPageChanged ), bottomNavigationBar: new BottomNavigationBar(items: [ new BottomNavigationBarItem( icon: new Icon(Icons.laptop_chromebook), title: new Text("主頁"), backgroundColor: Colors.grey ), new BottomNavigationBarItem( icon: new Icon(Icons.list), title: new Text("分類"),backgroundColor: Colors.grey), new BottomNavigationBarItem( icon: new Icon(Icons.local_grocery_store), title: new Text("購物車")), new BottomNavigationBarItem(icon: new Icon(Icons.person), title: new Text("我的")) ], onTap: onTap, currentIndex: page ), ); } @override void initState() { super.initState(); pageController = new PageController(initialPage: this.page); } void onTap(int index) { pageController.animateToPage( index, duration: const Duration(milliseconds: 300), curve: Curves.ease); } void onPageChanged(int page) { setState(() { this.page = page; }); } }
其中,各個頁面的主要聲明
底部導(dǎo)航欄的內(nèi)容填充
二.其他四個頁面的主要代碼
import 'package:flutter/material.dart'; class Classify extends StatelessWidget { @override Widget build(BuildContext context) { // TODO: implement build return new Scaffold( body: new Center( child: new Text("分類"), ), ); } }
關(guān)于使用Flutter怎么實(shí)現(xiàn)底部導(dǎo)航欄效果就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
本文標(biāo)題:使用Flutter怎么實(shí)現(xiàn)底部導(dǎo)航欄效果-創(chuàng)新互聯(lián)
URL地址:http://muchs.cn/article48/cocoep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、關(guān)鍵詞優(yōu)化、品牌網(wǎng)站制作、建站公司、企業(yè)網(wǎng)站制作、網(wǎng)站維護(hù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容