码迷,mamicode.com
首页 > 其他好文 > 详细

BottomNavigationBar + BottomNavigationBarItem导航的另外一种用法

时间:2019-04-15 16:10:23      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:ons   nta   bottom   bsp   home   idp   int   return   VID   

import package:flutter/material.dart;
import News.dart;
import Video.dart;
import Chat.dart;
import MyId.dart;

class AppTwo extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(home: Home());
}

class Home extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  int _currentIndex = 0;
  final List<Widget> _children = [
    NewsPage(),
    VideoPage(),
    ChatPage(),
    MyIdPage()
  ];

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
//      appBar: AppBar(
//        title: Text("第二种方式"),
//        centerTitle: true,
//      ),
      body: _children[_currentIndex],
//      CupertinoTabBar 是IOS分格
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        onTap: onTabTapped,
        items: [
          BottomNavigationBarItem(
              title: new Text("Home"), icon: new Icon(Icons.home)),
          BottomNavigationBarItem(
              title: new Text("List"), icon: new Icon(Icons.list)),
          BottomNavigationBarItem(
              title: new Text("Message"), icon: new Icon(Icons.message)),
        ],
      ),
    );

  }

  void onTabTapped(int index) {
    setState(() {
      _currentIndex = index;
    });
  }
}
import package:flutter/material.dart;
import Guide.dart;

void main() => runApp(new AppTwo());

 

BottomNavigationBar + BottomNavigationBarItem导航的另外一种用法

标签:ons   nta   bottom   bsp   home   idp   int   return   VID   

原文地址:https://www.cnblogs.com/xiongwei/p/10711041.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!