zoukankan      html  css  js  c++  java
  • BottomNavigationBar + BottomNavigationBarItem导航的另外一种用法

    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());
  • 相关阅读:
    Git 从入门到入坑
    单件模式(单例模式)
    装饰者模式
    观察者模式
    设计模式入门
    SpringBoot + Mybatis + Redis 整合入门项目
    Spring Boot 前后端交互及参数传递
    Spring Securtiy 认证流程(源码分析)
    Spring Boot 静态页面跳转
    第一条手机验证码
  • 原文地址:https://www.cnblogs.com/xiongwei/p/10711041.html
Copyright © 2011-2022 走看看