赞
踩
- import 'package:color_dart/color_dart.dart';
- import 'package:flutter/material.dart';
-
- class Order extends StatefulWidget {
- static _OrderState _orderState;
-
- getAppBar() {
- return _orderState.createAppBar();
- }
-
- Order() {
- _orderState = _OrderState();
- }
-
- @override
- _OrderState createState() => _OrderState();
- }
-
- class _OrderState extends State<Order> with TickerProviderStateMixin {
- static List<Tab> tabs = [
- Tab(text: '全部'),
- Tab(text: '未完成'),
- Tab(
- text: '已完成',
- )
- ];
- static TabController _tabController;
-
- AppBar createAppBar() {
- _tabController = TabController(vsync: this, length: tabs.length);
- return AppBar(
- backgroundColor: Colors.white,
- brightness: Brightness.dark,
- elevation: 0,
- centerTitle: true,
- title: Text(
- "订单列表",
- style: TextStyle(
- color: rgba(56, 56, 56, 1),
- fontSize: 18,
- fontWeight: FontWeight.bold),
- ),
- bottom: PreferredSize( //常用在appbar的bottom 可以对子控制没有约束
- preferredSize: Size.fromHeight(44),
- child: Container(
- child: Column(
- children: [
- SizedBox(
- height: 1,
- width: double.infinity,
- child: Padding(
- padding: EdgeInsets.symmetric(horizontal: 20),
- child: Divider(
- color: Colors.yellow,
- height: 2,
- )),
- ),
- TabBar(
- tabs: tabs,
- labelColor: rgba(136, 175, 213, 1),
- labelStyle: TextStyle(fontWeight: FontWeight.bold),
- unselectedLabelStyle: TextStyle(fontSize: 15),
- unselectedLabelColor: rgba(80, 80, 80, 1),
- controller: _tabController,
- ),
- ],
- ),
- )));
- }
-
- @override
- Widget build(BuildContext context) {
- return Container(
- color: rgba(248, 248, 248, 1),
- child: TabBarView(
- children: [Text("xxxx"),
- Text("xxxx"),
- Text("xxxx")
- ],
- controller: _tabController,
- ),
- );
- }
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。