zoukankan      html  css  js  c++  java
  • 底部导航栏2

    代码:

    import 'package:flutter/material.dart';
    import 'pages/ariplay_screen.dart';
    import 'pages/email_screen.dart';
    import 'pages/home_screen.dart';
    import 'pages/scanner_screen.dart';
    class BottomNavigationWidget extends StatefulWidget {
    _BottomNavigationWidgetState createState() => _BottomNavigationWidgetState();
    }

    class _BottomNavigationWidgetState extends State<BottomNavigationWidget> {
    final _bottomNavColor = Colors.blue;
    int _currentIndex = 0;
    List<Widget> list = List();
    @override
    void initState(){
    list
    ..add(HomeScreen())
    ..add(ScannerScreen())
    ..add(EmailScreen())
    ..add(AirplayScreen());
    super.initState();
     
    }


    @override
    Widget build(BuildContext context) {
    return Scaffold(
    body: list[_currentIndex],
    bottomNavigationBar: BottomNavigationBar(
    items: [
    BottomNavigationBarItem(
    icon: Icon(
    Icons.home,
    color: _bottomNavColor,
    ),
    title: Text(
    'home',
    style: TextStyle(color: _bottomNavColor),
    )
    ),
    BottomNavigationBarItem(
    icon: Icon(
    Icons.email,
    color: _bottomNavColor,
    ),
    title: Text(
    'Email',
    style: TextStyle(color: _bottomNavColor),
    )
    ),
    BottomNavigationBarItem(
    icon: Icon(
    Icons.airplay,
    color: _bottomNavColor,
    ),
    title: Text(
    'Airplay',
    style: TextStyle(color: _bottomNavColor),
    )
    ),
    BottomNavigationBarItem(
    icon: Icon(
    Icons.scanner,
    color: _bottomNavColor,
    ),
    title: Text(
    'Scnner',
    style: TextStyle(color: _bottomNavColor),
    )
    )
     
    ],
    currentIndex: _currentIndex,
    onTap: (int index){
    setState(() {
    _currentIndex = index;
    });
    },
    ),
    );
    }
    }
     
    每个假页面的代码
    import 'package:flutter/material.dart';
    class AirplayScreen extends StatelessWidget {

    @override
    Widget build(BuildContext context) {
    return Scaffold(
    appBar: AppBar(title: Text('Airplay'),),
    body: Center(
    child: Text('Airplay'),
    ),
    );
    }
    }
    总结:
     

    底部导航栏2

    点击导航栏 变换布局

    Ontap:(int index){

    setState(){

    _xxxx = index;/

    }

    }

    //高亮状态的切换

    currentIndex : _xxxx

  • 相关阅读:
    NserviceBus+rabbitmq
    c#调用Mysql带参数的存储过程
    datatable list 之前相互转换
    (gridcontrol等)通用导出excel z
    异步数据库查询 Z
    Gridview导出EXCEL(多页) z
    [自制简单操作系统] 4、计时器(线性表实现优化中断)
    [JAVA] 基于TCP的起重机运行模拟器
    [自制简单操作系统] 3、内存管理和窗口叠加
    [自制简单操作系统] 2、鼠标及键盘中断处理事件[PICGDTIDTFIFO]
  • 原文地址:https://www.cnblogs.com/pp-pping/p/12172985.html
Copyright © 2011-2022 走看看