美文网首页
Flutter - TabBar 封装JhTopTabBar

Flutter - TabBar 封装JhTopTabBar

作者: 西半球_ | 来源:发表于2020-05-07 17:36 被阅读0次

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

效果图:

JhTopTabBar.jpg JhTopTabBar.jpg

demo代码

import 'package:flutter/material.dart';
import 'package:jh_flutter_demo/JhTools/widgets/jhTopTabBar.dart';


class TopTabBarTest1Page extends StatefulWidget {
  @override
  _TopTabBarTest1PageState createState() => _TopTabBarTest1PageState();
}

class _TopTabBarTest1PageState extends State<TopTabBarTest1Page> {


  List<JhTopTabBarModel> model = [
    JhTopTabBarModel(title: '标题一', widget:
    Container(
      alignment: Alignment.center,
      child: Text('页面一', textScaleFactor: 3),
    )),
    JhTopTabBarModel(title: '标题二', widget:  Container(
      alignment: Alignment.center,
      child: Text('页面二', textScaleFactor: 3),
    )),
  ];

  @override
  Widget build(BuildContext context) {
    return
        JhTopTabBar(
          title: '标题',
          tabModelArr: model,
          showCenterLine: true,
          rightText: '添加',
          rightItemCallBack: (){
            print('点击右侧nav');
          },
          switchPageCallBack: (index){
            print('切换到第$index页');
          },
        );

  }
}


相关文章

网友评论

      本文标题:Flutter - TabBar 封装JhTopTabBar

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