当前位置:   article > 正文

flutter的tabbar_flutter tab 获取text

flutter tab 获取text

  1. import 'package:color_dart/color_dart.dart';
  2. import 'package:flutter/material.dart';
  3. class Order extends StatefulWidget {
  4. static _OrderState _orderState;
  5. getAppBar() {
  6. return _orderState.createAppBar();
  7. }
  8. Order() {
  9. _orderState = _OrderState();
  10. }
  11. @override
  12. _OrderState createState() => _OrderState();
  13. }
  14. class _OrderState extends State<Order> with TickerProviderStateMixin {
  15. static List<Tab> tabs = [
  16. Tab(text: '全部'),
  17. Tab(text: '未完成'),
  18. Tab(
  19. text: '已完成',
  20. )
  21. ];
  22. static TabController _tabController;
  23. AppBar createAppBar() {
  24. _tabController = TabController(vsync: this, length: tabs.length);
  25. return AppBar(
  26. backgroundColor: Colors.white,
  27. brightness: Brightness.dark,
  28. elevation: 0,
  29. centerTitle: true,
  30. title: Text(
  31. "订单列表",
  32. style: TextStyle(
  33. color: rgba(56, 56, 56, 1),
  34. fontSize: 18,
  35. fontWeight: FontWeight.bold),
  36. ),
  37. bottom: PreferredSize( //常用在appbar的bottom 可以对子控制没有约束
  38. preferredSize: Size.fromHeight(44),
  39. child: Container(
  40. child: Column(
  41. children: [
  42. SizedBox(
  43. height: 1,
  44. width: double.infinity,
  45. child: Padding(
  46. padding: EdgeInsets.symmetric(horizontal: 20),
  47. child: Divider(
  48. color: Colors.yellow,
  49. height: 2,
  50. )),
  51. ),
  52. TabBar(
  53. tabs: tabs,
  54. labelColor: rgba(136, 175, 213, 1),
  55. labelStyle: TextStyle(fontWeight: FontWeight.bold),
  56. unselectedLabelStyle: TextStyle(fontSize: 15),
  57. unselectedLabelColor: rgba(80, 80, 80, 1),
  58. controller: _tabController,
  59. ),
  60. ],
  61. ),
  62. )));
  63. }
  64. @override
  65. Widget build(BuildContext context) {
  66. return Container(
  67. color: rgba(248, 248, 248, 1),
  68. child: TabBarView(
  69. children: [Text("xxxx"),
  70. Text("xxxx"),
  71. Text("xxxx")
  72. ],
  73. controller: _tabController,
  74. ),
  75. );
  76. }
  77. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/431880
推荐阅读
相关标签
  

闽ICP备14008679号