index.dart 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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: ListView(children: [
  45. Column(
  46. children: [
  47. Container(
  48. padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
  49. decoration: BoxDecoration(color: Colors.white),
  50. // child:Search(),
  51. child: Container(
  52. height: 32.w,
  53. decoration: const BoxDecoration(color: Colors.white),
  54. child: GestureDetector(
  55. onTap: () {
  56. Get.toNamed('/searchPage');
  57. },
  58. child: Container(
  59. decoration: const BoxDecoration(
  60. // color: Colors.red,
  61. color: Color(0x30cccccc),
  62. borderRadius: BorderRadius.all(Radius.circular(25)),
  63. ),
  64. child: Row(
  65. children: [
  66. Padding(
  67. padding: EdgeInsets.fromLTRB(15, 0, 5, 0),
  68. child: Icon(
  69. Icons.search,
  70. size: 19,
  71. color: Color(0xff666666),
  72. ),
  73. ),
  74. Text(
  75. '请输入关键字查询',
  76. style: TextStyle(
  77. color: Color(0xff666666), fontSize: 14),
  78. )
  79. ],
  80. ),
  81. )
  82. // Search(),
  83. )),
  84. ),
  85. TabBar(
  86. labelStyle: TextStyle(
  87. fontSize: ScreenUtil().setSp(19),
  88. fontWeight: FontWeight.bold), //选中的样式
  89. unselectedLabelStyle:
  90. TextStyle(fontSize: ScreenUtil().setSp(16)), //未选中的样式
  91. controller: _controller,
  92. isScrollable: true, //可滚动
  93. indicatorColor: Colors.black, //指示器的颜色
  94. labelColor: Colors.black, //选中文字颜色
  95. unselectedLabelColor: Color(0xffadadad),
  96. // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
  97. tabs: tabText.map((e) => Tab(text: e)).toList(),
  98. onTap: (int i) {
  99. print('当前+${i}');
  100. },
  101. ),
  102. Container(
  103. child: Column(
  104. children: [
  105. CarsCard(),
  106. CarsCard(),
  107. CarsCard(),
  108. CarsCard(),
  109. ],
  110. ),
  111. )
  112. ],
  113. )
  114. ]));
  115. }
  116. }