index.dart 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import 'package:carousel_slider/carousel_slider.dart';
  2. import 'package:farmer_client/pages/TabBar/widgets/home/widgets/headers.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:get/get.dart';
  6. import 'package:get/get_core/src/get_main.dart';
  7. import '../../../../widgets/CarsCard.dart';
  8. import '../../../../widgets/Search.dart';
  9. import '../../../MoreCars/index.dart';
  10. class HomePage extends StatefulWidget {
  11. const HomePage({Key? key}) : super(key: key);
  12. @override
  13. State<HomePage> createState() => _HomePageState();
  14. }
  15. class _HomePageState extends State<HomePage> {
  16. final CarouselController _controller = CarouselController();
  17. final List<String> imgList = [
  18. 'https://images.unsplash.com/photo-1520342868574-5fa3804e551c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6ff92caffcdd63681a35134a6770ed3b&auto=format&fit=crop&w=1951&q=80',
  19. 'https://images.unsplash.com/photo-1522205408450-add114ad53fe?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=368f45b0888aeb0b7b08e3a1084d3ede&auto=format&fit=crop&w=1950&q=80',
  20. 'https://images.unsplash.com/photo-1519125323398-675f0ddb6308?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=94a1e718d89ca60a6337a6008341ca50&auto=format&fit=crop&w=1950&q=80',
  21. 'https://images.unsplash.com/photo-1523205771623-e0faa4d2813d?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=89719a0d55dd05e2deae4120227e6efc&auto=format&fit=crop&w=1953&q=80',
  22. 'https://images.unsplash.com/photo-1508704019882-f9cf40e475b4?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=8c6e5e3aba713b17aa1fe71ab4f0ae5b&auto=format&fit=crop&w=1352&q=80',
  23. 'https://images.unsplash.com/photo-1519985176271-adb1088fa94c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a0c8d632e977f94e5d312d9893258f59&auto=format&fit=crop&w=1355&q=80'
  24. ];
  25. @override
  26. Widget build(BuildContext context) {
  27. return Container(
  28. alignment: Alignment.center,
  29. padding: EdgeInsets.fromLTRB(15.w, 0, 15.w, 0),
  30. child: ListView(
  31. children: [
  32. Container(
  33. width:20.w ,
  34. child: TypeHeader(type: true,),
  35. ),
  36. Container(
  37. margin: EdgeInsets.fromLTRB(0, 15, 0, 0),
  38. child: CarouselSlider(
  39. //API https://pub.dev/documentation/carousel_slider/latest/carousel_options/CarouselOptions-class.html
  40. items:imgList
  41. .map((item) => Container(
  42. child: Center(
  43. child:
  44. Image.network(item, fit: BoxFit.cover, width: 350.w)),
  45. ))
  46. .toList(),
  47. options: CarouselOptions(
  48. autoPlay: true,
  49. enlargeCenterPage: false,//图片中心放大
  50. viewportFraction: 1,//每个页面应占据的视口部分。默认为 0.8,这意味着每个页面填充 80% 的轮播。
  51. // aspectRatio: 1.6,//纵横比
  52. height: 214.w,
  53. initialPage: 1,//初始页
  54. ),
  55. ),
  56. ),
  57. Container(
  58. margin: EdgeInsets.fromLTRB(0, 20, 0, 20),
  59. child: Column(
  60. children: [
  61. Row(
  62. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  63. children: [
  64. Container(
  65. child: Row(
  66. children: [
  67. Padding(padding: EdgeInsets.fromLTRB(0, 0, 8, 0),
  68. child:Image(image: AssetImage('images/icons/carsListImga.png'),fit: BoxFit.cover,width: 20.w,),
  69. ),
  70. Text('农机列表',
  71. style: TextStyle(
  72. color: Color(0xff222222),
  73. fontSize: 20.sp,
  74. fontWeight: FontWeight.bold
  75. ),
  76. )
  77. ],
  78. ),
  79. ),
  80. Container(
  81. child:GestureDetector(
  82. child: Text('更多 >>'),
  83. onTap: (){
  84. print('点我进入农机搜索/更多页');
  85. Get.to(MoreCars());
  86. },
  87. ),
  88. )
  89. ],
  90. ),
  91. CarsCard(),
  92. CarsCard(),
  93. CarsCard(),
  94. ],
  95. )
  96. ),
  97. ],
  98. ),
  99. );
  100. }
  101. }