国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Flutter實現底部導航欄

2019-10-21 21:25:29
字體:
來源:轉載
供稿:網友

本文實例為大家分享了Flutter實現底部導航欄的具體代碼,供大家參考,具體內容如下

效果

Flutter,底部導航欄

Flutter,底部導航欄

實現

先將自動生成的main.dart里面的代碼刪除,

import 'package:flutter/material.dart';import 'package:flutter_guohe/pages/main.dart'; void main() { runApp(new Guohe());}

創建app.dart作為首頁的頁面文件

class Guohe extends StatefulWidget { @override GuoheState createState() => new GuoheState();} class GuoheState extends State<Guohe> { @override Widget build(BuildContext context) {  }}

創建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), //設置appbar背景顏色   centerTitle: true, //設置標題是否局中  ),  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,

第一個屬性是控制標簽顏色,這里我選了紫色,第二個屬性是未選中標簽時的顏色。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平原县| 阿勒泰市| 灵璧县| 苍南县| 子长县| 莫力| 靖宇县| 谢通门县| 淮北市| 神农架林区| 临泽县| 葫芦岛市| 扶沟县| 屯昌县| 越西县| 许昌县| 日照市| 邵阳市| 扎兰屯市| 铜鼓县| 凌云县| 湘潭市| 洞头县| 荔波县| 广丰县| 绍兴市| 五峰| 东至县| 临桂县| 石嘴山市| 宾阳县| 韩城市| 岚皋县| 府谷县| 尼木县| 英德市| 云和县| 班玛县| 兰西县| 新津县| 陕西省|