美文网首页
Flutter标签控制器

Flutter标签控制器

作者: CYC666 | 来源:发表于2019-12-27 12:22 被阅读0次

    import 'package:demo7/%E6%88%91%E7%9A%84/Mine.dart';

    import 'package:demo7/%E7%9F%A5%E8%AF%86%E5%BA%93/Library.dart';

    import 'package:demo7/%E9%A6%96%E9%A1%B5/Home.dart';

    import 'package:demo7/PCH.dart';

    import 'package:flutter/material.dart';

    class BaseTabBarextends StatefulWidget {

    @override

      _BaseTabBarState createState() =>_BaseTabBarState();

    }

    class _BaseTabBarStateextends State {

    final Homevc1 =Home();

    final Libraryvc2 =Library();

    final Minevc3 =Mine();

    ListvcList =List();

    intcurrentPage =0;

    @override

      void initState() {

    // TODO: implement initState

        super.initState();

    vcList

          ..add(vc1)

    ..add(vc2)

    ..add(vc3);

    }

    @override

      Widget build(BuildContext context) {

    return Scaffold(

    body:vcList[currentPage],

    bottomNavigationBar:BottomNavigationBar(

    type: BottomNavigationBarType.fixed,// 间距一致

            showUnselectedLabels:true,// 显示非选中图标文本

            currentIndex:currentPage,// 当前选中的标签

            selectedFontSize: FontC,

    unselectedFontSize: FontC,

    onTap: (index) {

    setState(() {

    currentPage = index;

    });

    },

    items: [

    BottomNavigationBarItem(

    title:Text('首页', style:TextStyle(color:currentPage ==0 ? PublicColor : LabelColorTab),),

    icon:Container(child:Image.asset('lib/Images/tabHome0.png'), width:25, height:25,),

    activeIcon:Container(child:Image.asset('lib/Images/tabHome.png'), width:25, height:25,),

    ),

    BottomNavigationBarItem(

    title:Text('知识库', style:TextStyle(color:currentPage ==1 ? PublicColor : LabelColorTab),),

    icon:Container(child:Image.asset('lib/Images/tabLibrary0.png'), width:25, height:25,),

    activeIcon:Container(child:Image.asset('lib/Images/tabLibrary.png'), width:25, height:25,),

    ),

    BottomNavigationBarItem(

    title:Text('我的', style:TextStyle(color:currentPage ==2 ? PublicColor : LabelColorTab),),

    icon:Container(child:Image.asset('lib/Images/tabMine0.png'), width:25, height:25,),

    activeIcon:Container(child:Image.asset('lib/Images/tabMine.png'), width:25, height:25,),

    ),

    BottomNavigationBarItem(

    title:Text('我的', style:TextStyle(color:currentPage ==2 ? PublicColor : LabelColorTab),),

    icon:Container(child:Image.asset('lib/Images/tabMine0.png'), width:25, height:25,),

    activeIcon:Container(child:Image.asset('lib/Images/tabMine.png'), width:25, height:25,),

    ),

    ],

    ),

    );

    }

    }

    相关文章

      网友评论

          本文标题:Flutter标签控制器

          本文链接:https://www.haomeiwen.com/subject/mhfdoctx.html