美文网首页Flutterflutter
Flutter - tabbar实现,去掉水波纹效果

Flutter - tabbar实现,去掉水波纹效果

作者: 西半球_ | 来源:发表于2020-03-08 12:08 被阅读0次
demo 地址: https://github.com/iotjin/jh_flutter_demo

代码

import 'package:flutter/material.dart';
import 'package:jh_flutter_demo/one/one_page.dart';
import 'package:jh_flutter_demo/Two/two_page.dart';
import 'package:jh_flutter_demo/Three/three_page.dart';
import './four/four_page.dart';
import './JhTools/jhImageTool.dart';

class BaseTabBar extends StatefulWidget {
  BaseTabBar({Key key}) : super(key: key);

  _BaseTabBarState createState() => _BaseTabBarState();
}

class _BaseTabBarState extends State<BaseTabBar> {

  int _currentIndex=0;
  List <Widget>_pageList=[
    OnePage(),
    TwoPage(),
    ThreePage(),
    FourPage()
  ];
  static double _iconWH = 25.0;
  static double _fontSize = 10.0;
  List<BottomNavigationBarItem> bottomTabs = [

    BottomNavigationBarItem(
      title: Text("微信"),
      icon: Jh_loadAssetImage('tab/nav_tab_1',width: _iconWH),
      activeIcon: Jh_loadAssetImage('tab/nav_tab_1_on',width: _iconWH),
    ),
    BottomNavigationBarItem(
      title: Text("通讯录"),
      icon: Jh_loadAssetImage('tab/nav_tab_2',width: _iconWH),
      activeIcon: Jh_loadAssetImage('tab/nav_tab_2_on',width: _iconWH),
    ),
    BottomNavigationBarItem(
      title: Text("朋友圈"),
      icon: Jh_loadAssetImage('tab/nav_tab_3',width: _iconWH),
      activeIcon: Jh_loadAssetImage('tab/nav_tab_3_on',width: _iconWH),
    ),
    BottomNavigationBarItem(
      title: Text("我的"),
      icon: Jh_loadAssetImage('tab/nav_tab_4',width: _iconWH),
      activeIcon: Jh_loadAssetImage('tab/nav_tab_4_on',width: _iconWH),
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
//      backgroundColor: Colors.white,
      body: IndexedStack(
        index: _currentIndex,
        children: _pageList,
      ),
      bottomNavigationBar:
        Theme(
          data: ThemeData(
          highlightColor: Color.fromRGBO(0, 0, 0, 0),
          splashColor: Color.fromRGBO(0, 0, 0, 0),
          ),
          child:
          BottomNavigationBar(
//        unselectedItemColor:Colors.red,  //未选中颜色
//        selectedItemColor:Colors.yellow,  //选中颜色
            fixedColor: Color(0xFF3BB815),  //选中的颜色
            unselectedFontSize:_fontSize,
            selectedFontSize:_fontSize,
            type:BottomNavigationBarType.fixed,   //配置底部BaseTabBar可以有多个按钮
            items: bottomTabs,
            currentIndex: this._currentIndex,   //配置对应的索引值选中
            onTap: (int index){
              setState(() {  //改变状态
                this._currentIndex=index;
              });
            },
          ),

        )


//      BottomNavigationBar(
////        unselectedItemColor:Colors.red,  //未选中颜色
////        selectedItemColor:Colors.yellow,  //选中颜色
//        fixedColor: Color(0xFF3BB815),  //选中的颜色
//        unselectedFontSize:_fontSize,
//        selectedFontSize:_fontSize,
//        type:BottomNavigationBarType.fixed,   //配置底部BaseTabBar可以有多个按钮
//        items: bottomTabs,
//        currentIndex: this._currentIndex,   //配置对应的索引值选中
//        onTap: (int index){
//          setState(() {  //改变状态
//            this._currentIndex=index;
//          });
//        },
//      ),


    );
  }
}


/*-----------------------------------------------------------------------------*/
/*
BottomNavigationBar({
    Key key,
    @required this.items,  //必须有的item
    this.onTap,  //点击事件
    this.currentIndex = 0,  //当前选中
    this.elevation = 8.0,  //高度
    BottomNavigationBarType type,  //排列方式
    Color fixedColor,    //'Either selectedItemColor or fixedColor can be specified, but not both'
    this.backgroundColor,  //背景
    this.iconSize = 24.0,  //icon大小
    Color selectedItemColor,  //选中颜色
    this.unselectedItemColor,  //未选中颜色
    this.selectedIconTheme = const IconThemeData(),
    this.unselectedIconTheme = const IconThemeData(),
    this.selectedFontSize = 14.0,  //选中文字大小
    this.unselectedFontSize = 12.0,  //未选中文字大小
    this.selectedLabelStyle,
    this.unselectedLabelStyle,
    this.showSelectedLabels = true, //是否显示选中的Item的文字
    bool showUnselectedLabels,  //是否显示未选中的Item的问题
  })

 */
demo 地址: https://github.com/iotjin/jh_flutter_demo

相关文章

  • Flutter - tabbar实现,去掉水波纹效果

    demo 地址: https://github.com/iotjin/jh_flutter_demo 代码 dem...

  • flutter开发小技巧

    ps:记录flutter开发过程中一些小知识点 1.去掉点击事件的水波纹效果 如果想全局去掉该效果可以在main....

  • Fluter:抽屉效果

    效果图 flutter的抽屉效果是使用Drawer组件实现的 Drawer可以添加头部属性: tabbar底部导航...

  • Flutter小知识点

    1、部分导入模块: 2、Flutter InkWell-水波纹效果: 实现:包一层 Material,将背景色设置...

  • Flutter_Weather今日热点模块实现

    Flutter_Weather今日热点模块实现,效果图如下: 首页布局实现 代码如下: 因为TabBar的标题是网...

  • Flutter 去掉 水波纹 点击 高亮 效果

    MaterialApp( theme: ThemeData( splashColor:Colors....

  • iOS tabBar的设置

    一、默认tabbar是带有蒙版效果的,想去掉蒙版效果的话self.tabBar.barTintColor = UI...

  • 2019-11-05

    水波纹,interpolator加速器属性值 ------- 水波纹效果实现: 点击水波纹效果:只有android...

  • Flutter:底部Tabbar

    这篇文章介绍Flutter的底部Tabbar的实现,将从三种实现方式介绍 效果图 第一种:bottomNaviga...

  • 2019-09-25

    ImageButtom 实现点击水波纹效果和图标切换 一个简单的点击效果: 一:水波纹的实现 5.0以上bu...

网友评论

    本文标题:Flutter - tabbar实现,去掉水波纹效果

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