import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../widgets/CarsCard.dart'; import '../../widgets/Search.dart'; import '../TabBar/widgets/home/widgets/headers.dart'; class MoreCars extends StatefulWidget { const MoreCars({Key? key}) : super(key: key); @override State createState() => _MoreCarsState(); } class _MoreCarsState extends State with TickerProviderStateMixin { late TabController _controller = TabController(length: tabText.length, vsync: this); List tabText = [ '全部', '播种机', '收割机', '挺长名字的农机选项分类', ]; @override void initState() { // TODO: implement initState super.initState(); } @override Widget build(BuildContext context) { // _controller=TabController(length: tabText.length, vsync: this); return Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( elevation: 0, centerTitle: true, backgroundColor: Colors.white, title: Text( '更多', style: TextStyle( color: Colors.black, fontSize: 17.sp, letterSpacing: 2, fontWeight: FontWeight.bold), ), ), body: Container( decoration: BoxDecoration( color: Colors.white ), child: ListView( children: [Column( children: [ Container( padding: EdgeInsets.fromLTRB(0, 15, 0, 15), width: 350.w, child: TypeHeader(type: false,), ), TabBar( labelStyle: TextStyle(fontSize: ScreenUtil().setSp(19),fontWeight: FontWeight.bold), //选中的样式 unselectedLabelStyle: TextStyle(fontSize:ScreenUtil().setSp(16)), //未选中的样式 controller: _controller, isScrollable: true, //可滚动 indicatorColor: Colors.black, //指示器的颜色 labelColor: Colors.black, //选中文字颜色 unselectedLabelColor: Color(0xffadadad), // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽 tabs: tabText.map((e) => Tab(text: e)).toList(), onTap: (int i) { print('当前+${i}'); }, ), Container( child: Column( children: [ CarsCard(), CarsCard(), CarsCard(), CarsCard(), ], ) , ) ], )] ), ) ); } }