欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Flutter實(shí)現(xiàn)底部導(dǎo)航欄效果

 更新時(shí)間:2018年08月22日 17:40:35   作者:BrodyWu  
這篇文章主要為大家詳細(xì)介紹了Flutter實(shí)現(xiàn)底部導(dǎo)航欄效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

大家最近都在討論新鮮技術(shù)-flutter,小編也在學(xué)習(xí)中,遇到大家都遇到的問(wèn)題,底部導(dǎo)航。下面給大家貼出底部導(dǎo)航的編寫,主要參考了lime這個(gè)項(xiàng)目。

上代碼

一.在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("主頁(yè)"),
     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("購(gòu)物車")),
    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;
  });
 }


}

其中,各個(gè)頁(yè)面的主要聲明

底部導(dǎo)航欄的內(nèi)容填充

二.其他四個(gè)頁(yè)面的主要代碼

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("分類"),
   ),
  );
 }
}

其他3個(gè)頁(yè)面的代碼是一樣的,具體邏輯由需求去填寫

三.效果圖

效果圖

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論