index.dart 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import '../../widgets/CarsCard.dart';
  4. import '../../widgets/Search.dart';
  5. import '../TabBar/widgets/home/widgets/headers.dart';
  6. class MoreCars extends StatefulWidget {
  7. const MoreCars({Key? key}) : super(key: key);
  8. @override
  9. State<MoreCars> createState() => _MoreCarsState();
  10. }
  11. class _MoreCarsState extends State<MoreCars> with TickerProviderStateMixin {
  12. late TabController _controller = TabController(length: tabText.length, vsync: this);
  13. List<String> tabText= [
  14. '全部',
  15. '播种机',
  16. '收割机',
  17. '挺长名字的农机选项分类',
  18. ];
  19. @override
  20. void initState() {
  21. // TODO: implement initState
  22. super.initState();
  23. }
  24. @override
  25. Widget build(BuildContext context) {
  26. // _controller=TabController(length: tabText.length, vsync: this);
  27. return Scaffold(
  28. resizeToAvoidBottomInset: false,
  29. appBar: AppBar(
  30. elevation: 0,
  31. centerTitle: true,
  32. backgroundColor: Colors.white,
  33. title:Text(
  34. '更多',
  35. style: TextStyle(
  36. color: Colors.black,
  37. fontSize: 17.sp,
  38. letterSpacing: 2,
  39. fontWeight: FontWeight.bold),
  40. ),
  41. ),
  42. body: Container(
  43. decoration: BoxDecoration(
  44. color: Colors.white
  45. ),
  46. child: ListView(
  47. children: [Column(
  48. children: [
  49. Container(
  50. padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
  51. width: 350.w,
  52. child: TypeHeader(type: false,),
  53. ),
  54. TabBar(
  55. labelStyle: TextStyle(fontSize: ScreenUtil().setSp(19),fontWeight: FontWeight.bold), //选中的样式
  56. unselectedLabelStyle: TextStyle(fontSize:ScreenUtil().setSp(16)), //未选中的样式
  57. controller: _controller,
  58. isScrollable: true, //可滚动
  59. indicatorColor: Colors.black, //指示器的颜色
  60. labelColor: Colors.black, //选中文字颜色
  61. unselectedLabelColor: Color(0xffadadad),
  62. // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
  63. tabs: tabText.map((e) => Tab(text: e)).toList(),
  64. onTap: (int i) {
  65. print('当前+${i}');
  66. },
  67. ),
  68. Container(
  69. child: Column(
  70. children: [
  71. CarsCard(),
  72. CarsCard(),
  73. CarsCard(),
  74. CarsCard(),
  75. ],
  76. )
  77. ,
  78. )
  79. ],
  80. )]
  81. ),
  82. )
  83. );
  84. }
  85. }