CarsCard.dart 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import 'package:flutter/foundation.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. class CarItem {
  5. late String name ;
  6. late num? price ;
  7. late num? distance ;
  8. CarItem({ required this.name,this.price,this.distance});
  9. }
  10. class CarsCard extends StatelessWidget {
  11. final CarItem item;
  12. const CarsCard({Key? key, required this.item,}) : super(key: key);
  13. @override
  14. Widget build(BuildContext context) {
  15. return Container(
  16. decoration: BoxDecoration(
  17. color: Color(0xfff2f2f2),
  18. ),
  19. width: 345.w,
  20. // height: 389.h,
  21. child: Column(
  22. children: [
  23. Image.network(
  24. "http://yz-shigongli.oss-accelerate.aliyuncs.com/2022-03/1648094119154-7b280bbf63105a8e90299e2d79c8c6ee.jpeg",
  25. width: 345.w,
  26. height: 230.h,
  27. fit: BoxFit.cover,
  28. ),
  29. Container(
  30. padding: EdgeInsets.fromLTRB(15, 20, 0, 0),
  31. child: Row(
  32. crossAxisAlignment: CrossAxisAlignment.start,
  33. verticalDirection: VerticalDirection.up,
  34. children: <Widget>[
  35. Container(
  36. child: Text(
  37. item.name,
  38. style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
  39. ),
  40. ),
  41. ],
  42. ),
  43. ),
  44. Container(
  45. padding: const EdgeInsets.fromLTRB(19, 0, 0, 0),
  46. child: Row(
  47. crossAxisAlignment: CrossAxisAlignment.start,
  48. verticalDirection: VerticalDirection.up,
  49. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  50. children: <Widget>[
  51. Container(
  52. child: RichText(
  53. text: const TextSpan(children: <InlineSpan>[
  54. TextSpan(
  55. text: '8555元/',
  56. style: TextStyle(
  57. color: Color(0xffce3800),
  58. fontSize: 22,
  59. fontWeight: FontWeight.bold)),
  60. TextSpan(
  61. text: '公顷',
  62. style: TextStyle(
  63. color: Color(0xffce3800),
  64. fontSize: 10,
  65. fontWeight: FontWeight.bold)),
  66. ]),
  67. ),
  68. ),
  69. Align(
  70. widthFactor: 1.2,
  71. heightFactor: 1.2,
  72. alignment: Alignment(1.2, -5),
  73. child: Container(
  74. margin: EdgeInsets.only(right: 13),
  75. width: 86.w, //+6
  76. height: 44.h, //+10
  77. child: ElevatedButton(
  78. onPressed: () {
  79. print('点我去预约${item.name}');
  80. },
  81. child: const Text(
  82. "预约",
  83. style: TextStyle(
  84. fontSize: 19,
  85. color: Colors.white,
  86. fontWeight: FontWeight.bold),
  87. ),
  88. style: ButtonStyle(
  89. backgroundColor:
  90. MaterialStateProperty.all(const Color(0xFFFF703B)),
  91. shape: MaterialStateProperty.all(
  92. const RoundedRectangleBorder(
  93. //这个0像素圆角style如果删掉的话,按钮会变成默认样式,自带圆角
  94. borderRadius:
  95. BorderRadius.all(Radius.circular(0)))),
  96. ),
  97. ),
  98. ),
  99. ),
  100. ],
  101. ),
  102. ),
  103. // 地址信息 进入地图
  104. Container(
  105. padding: EdgeInsets.fromLTRB(19, 20, 0, 10),
  106. child: Row(
  107. children: [
  108. Image.asset(
  109. "images/gpsImgae.png",
  110. width: 11.w,
  111. height: 13.h,
  112. fit: BoxFit.cover,
  113. ),
  114. Container(
  115. padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
  116. width: 300.w,
  117. child: Row(
  118. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  119. children: [
  120. Text(
  121. '距离当前位置2.6公里',
  122. style: TextStyle(
  123. fontSize: 15, fontWeight: FontWeight.bold),
  124. ),
  125. GestureDetector(
  126. child: Text(
  127. '进入地图 >>',
  128. style: TextStyle(
  129. fontSize: 15, fontWeight: FontWeight.bold),
  130. ),
  131. onTap: () {
  132. print('进入地图');
  133. },
  134. )
  135. ],
  136. )),
  137. ],
  138. )),
  139. ],
  140. ),
  141. );
  142. }
  143. }