import 'package:base_app/res/index.dart'; import 'package:fluintl/fluintl.dart'; import 'package:flutter/material.dart'; class StaticTabPage2 extends StatefulWidget { const StaticTabPage2({Key key, this.labelId, this.title, this.titleId}) : super(key: key); final String labelId; final String title; final String titleId; @override State<StatefulWidget> createState() { return new StaticTabPageState2(); } } class StaticTabPageState2 extends State<StaticTabPage2> with SingleTickerProviderStateMixin { TabController _controller; List<Tab> _tabs; @override void initState() { super.initState(); _controller = TabController(initialIndex: 0, length: 3, vsync: this); // 定义tab文字 _tabs = [ Tab(text: "选项卡1"), Tab(text: "选项卡2"), Tab(text: "选项卡3"), ]; } @override Widget build(BuildContext context) { // 子页面 List<Widget> _children = [ new Text("tab1"), new Text("tab2"), new Text("tab3") ]; return new Scaffold( appBar: new AppBar( elevation: 0.0, //控件的zindex, 可以隐藏阴影 title: new Text( widget.title ?? IntlUtil.getString(context, widget.titleId)), centerTitle: true, // 标题居中 bottom: TabBar( indicatorWeight: 4, // 标签高度 indicatorSize: TabBarIndicatorSize.tab, // 标签长度,等宽用tab, 实际用label indicatorColor: Colours.blue_light, // 选中时标签下方的颜色 controller: _controller, tabs: _tabs, ), ), body: new TabBarView(controller: _controller, children: _children)); } @override void dispose() { // for (int i = 0, length = _children.length; i < length; i++) { // _children[i].bloc.dispose(); // } super.dispose(); } }