index.dart 2.9KB

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