item_post.dart 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:jmrh/constant/styles.dart';
  4. class ItemPost extends StatefulWidget {
  5. ItemPost({Key key}) : super(key: key);
  6. @override
  7. _ItemPostState createState() => _ItemPostState();
  8. }
  9. class _ItemPostState extends State<ItemPost> {
  10. @override
  11. Widget build(BuildContext context) {
  12. return InkWell(
  13. child: Column(
  14. crossAxisAlignment: CrossAxisAlignment.stretch,
  15. children: [
  16. Container(
  17. padding: EdgeInsets.all(16),
  18. child: Row(
  19. children: [
  20. ClipOval(
  21. child: CachedNetworkImage(
  22. imageUrl: 'https://zhumj.oss-cn-hangzhou.aliyuncs.com/image/user.jpg',
  23. width: 26,
  24. height: 26,
  25. ),
  26. ),
  27. Expanded(
  28. child: Container(
  29. padding: EdgeInsets.symmetric(horizontal: 10),
  30. child: Text(
  31. '夏秋雨',
  32. style: TextStyle(fontSize: 14, color: Colors.black),
  33. overflow: TextOverflow.ellipsis,
  34. ),
  35. ),
  36. ),
  37. Text(
  38. '05-23',
  39. style: TextStyle(color: COLOR_TEXT_2, fontSize: 13),
  40. )
  41. ],
  42. ),
  43. ),
  44. Container(
  45. padding: EdgeInsets.symmetric(horizontal: 16),
  46. child: RichText(
  47. text: TextSpan(children: [
  48. WidgetSpan(
  49. alignment: PlaceholderAlignment.baseline,
  50. baseline: TextBaseline.alphabetic,
  51. child: Container(
  52. decoration: BoxDecoration(
  53. color: COLOR_PRIMARY,
  54. borderRadius: BorderRadius.all(Radius.circular(2)),
  55. ),
  56. padding: EdgeInsets.symmetric(horizontal: 4, vertical: 1),
  57. margin: EdgeInsets.only(right: 4),
  58. child: Text(
  59. '热议',
  60. style: TextStyle(color: Colors.white, fontSize: 11, height: 1.8),
  61. ),
  62. ),
  63. ),
  64. TextSpan(
  65. text: '自来水总是有一股消毒水味道,政府加大水质监管措施的几点建议',
  66. style: TextStyle(color: COLOR_TEXT_1, fontSize: 14, fontWeight: FontWeight.bold, height: 1.8))
  67. ]),
  68. ),
  69. ),
  70. Container(
  71. height: 46,
  72. child: Row(
  73. children: [
  74. Expanded(
  75. child: Row(children: [
  76. Image.asset('img/icon_redu.png'),
  77. Container(
  78. margin: EdgeInsets.only(left: 4),
  79. child: Text(
  80. '26461',
  81. style: TextStyle(color: COLOR_TEXT_3, fontSize: 13),
  82. ),
  83. )
  84. ], mainAxisAlignment: MainAxisAlignment.center),
  85. ),
  86. Expanded(
  87. child: Row(children: [
  88. Image.asset('img/icon_pingjia.png'),
  89. Container(
  90. margin: EdgeInsets.only(left: 4),
  91. child: Text(
  92. '3644',
  93. style: TextStyle(color: COLOR_TEXT_3, fontSize: 13),
  94. ),
  95. )
  96. ], mainAxisAlignment: MainAxisAlignment.center),
  97. ),
  98. Expanded(
  99. child: Row(children: [
  100. Image.asset('img/icon_dianzhan.png'),
  101. Container(
  102. margin: EdgeInsets.only(left: 4),
  103. child: Text(
  104. '11243',
  105. style: TextStyle(color: COLOR_TEXT_3, fontSize: 13),
  106. ),
  107. )
  108. ], mainAxisAlignment: MainAxisAlignment.center),
  109. )
  110. ],
  111. ),
  112. ),
  113. ],
  114. ),
  115. onTap: () {
  116. Navigator.of(context).pushNamed('/postDetail');
  117. },
  118. );
  119. }
  120. }