index.dart 3.8KB

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