Flutter實(shí)現(xiàn)底部導(dǎo)航欄
本文實(shí)例為大家分享了Flutter實(shí)現(xiàn)底部導(dǎo)航欄的具體代碼,供大家參考,具體內(nèi)容如下
效果
實(shí)現(xiàn)
先將自動生成的main.dart里面的代碼刪除,
import 'package:flutter/material.dart'; import 'package:flutter_guohe/pages/main.dart'; void main() { runApp(new Guohe()); }
創(chuàng)建app.dart作為首頁的頁面文件
class Guohe extends StatefulWidget { @override GuoheState createState() => new GuoheState(); } class GuoheState extends State<Guohe> { @override Widget build(BuildContext context) { } }
創(chuàng)建today.dart、kb.dart、playground.dart三個頁面文件作為tabview的填充文件,這里用playground.dart為例。
import 'package:flutter/material.dart'; class Playground extends StatefulWidget { @override PlaygroundState createState() => new PlaygroundState(); } class PlaygroundState extends State<Playground> { @override Widget build(BuildContext context) { return new MaterialApp( home: new Scaffold( appBar: new AppBar( title: new Text("操場"), backgroundColor: Color.fromARGB(255, 119, 136, 213), //設(shè)置appbar背景顏色 centerTitle: true, //設(shè)置標(biāo)題是否局中 ), body: new Center( child: new Text('操場'), ), ), ); } }
app.dart的完整代碼
/** * APP的主入口文件 */ import 'package:flutter/material.dart'; import 'package:flutter_guohe/pages/main/today.dart'; import 'package:flutter_guohe/pages/main/playground.dart'; import 'package:flutter_guohe/pages/main/kb.dart'; import 'package:flutter_guohe/pages/main/leftmenu.dart'; import 'package:flutter_guohe/common/eventBus.dart'; //果核的主界面 class Guohe extends StatefulWidget { @override GuoheState createState() => new GuoheState(); } class GuoheState extends State<Guohe> with SingleTickerProviderStateMixin { TabController controller; @override void initState() { controller = new TabController(length: 3, vsync: this); } @override void dispose() { controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return new MaterialApp( home: new Scaffold( drawer: new LeftMenu(), body: new TabBarView( controller: controller, children: <Widget>[ new Today(), new Kb(), new Playground(), ], ), bottomNavigationBar: new Material( color: Colors.white, child: new TabBar( controller: controller, labelColor: Colors.deepPurpleAccent, unselectedLabelColor: Colors.black26, tabs: <Widget>[ new Tab( text: "今日", icon: new Icon(Icons.brightness_5), ), new Tab( text: "課表", icon: new Icon(Icons.map), ), new Tab( text: "操場", icon: new Icon(Icons.directions_run), ), ], ), ), ), ); } }
其中
labelColor: Colors.deepPurpleAccent, unselectedLabelColor: Colors.black26,
第一個屬性是控制標(biāo)簽顏色,這里我選了紫色,第二個屬性是未選中標(biāo)簽時的顏色。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Flutter實(shí)現(xiàn)頂部導(dǎo)航欄功能
- flutter實(shí)現(xiàn)底部不規(guī)則導(dǎo)航欄
- flutter實(shí)現(xiàn)底部導(dǎo)航欄切換
- Flutter實(shí)現(xiàn)底部和頂部導(dǎo)航欄
- flutter實(shí)現(xiàn)底部導(dǎo)航欄
- Flutter實(shí)現(xiàn)底部導(dǎo)航欄創(chuàng)建詳解
- flutter BottomAppBar實(shí)現(xiàn)不規(guī)則底部導(dǎo)航欄
- Flutter底部導(dǎo)航欄的實(shí)現(xiàn)方式
- Flutter實(shí)現(xiàn)底部導(dǎo)航欄效果
- Flutter自定義底部導(dǎo)航欄的方法
相關(guān)文章
Android開發(fā)基礎(chǔ)實(shí)現(xiàn)最簡單的視頻播放示例
這篇文章主要為大家介紹了Android開發(fā)基礎(chǔ)實(shí)現(xiàn)最簡單的視頻播放示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02Android開發(fā)懸浮按鈕 Floating ActionButton的實(shí)現(xiàn)方法
這篇文章主要介紹了Android開發(fā)懸浮按鈕 Floating ActionButton的實(shí)現(xiàn)方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-09-09Android使用TabLayou+fragment+viewpager實(shí)現(xiàn)滑動切換頁面效果
這篇文章主要介紹了Android使用TabLayou+fragment+viewpager實(shí)現(xiàn)滑動切換頁面效果,需要的朋友可以參考下2017-05-05Android實(shí)現(xiàn)外部喚起應(yīng)用跳轉(zhuǎn)指定頁面的方法
這篇文章主要給大家介紹了關(guān)于Android實(shí)現(xiàn)外部喚起應(yīng)用跳轉(zhuǎn)指定頁面的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-12-12Android開發(fā)中LayoutInflater用法詳解
這篇文章主要介紹了Android開發(fā)中LayoutInflater用法,結(jié)合實(shí)例形式分析了LayoutInflater類的功能、作用、使用方法及相關(guān)注意事項,需要的朋友可以參考下2016-08-08Android 仿微信朋友圈點(diǎn)贊和評論彈出框功能
這篇文章主要介紹了Android 仿微信朋友圈點(diǎn)贊和評論彈出框功能的相關(guān)資料,非常不錯,具有參考解決價值,需要的朋友可以參考下2016-11-11