goods_comments.dart 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_note/provide/goods_detail_provide.dart';
  3. class GoodsComments extends StatelessWidget {
  4. final GoodsDetailProvide detailProvide;
  5. GoodsComments({Key key, this.detailProvide}) : super(key: key);
  6. @override
  7. Widget build(BuildContext context) {
  8. var _detail = detailProvide.detail.data;
  9. return Builder(builder: (ctx) {
  10. return CustomScrollView(
  11. slivers: <Widget>[
  12. SliverOverlapInjector(
  13. handle: NestedScrollView.sliverOverlapAbsorberHandleFor(ctx)),
  14. _detail.goodComments.isEmpty
  15. // 无评论
  16. ? SliverToBoxAdapter(
  17. child: Container(
  18. alignment: Alignment.center,
  19. height: 60.0,
  20. child: Text('暂时没有评论哦~')))
  21. // 评论列表
  22. : SliverFixedExtentList(
  23. delegate: SliverChildBuilderDelegate(
  24. (_, index) => Container(
  25. color: Colors.white,
  26. padding: const EdgeInsets.only(left: 12.0),
  27. child: Column(
  28. mainAxisAlignment: MainAxisAlignment.center,
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: [
  31. Text(
  32. '${_detail.goodComments[index].userName}'), // 评论者昵称
  33. Text(
  34. '${_detail.goodComments[index].comments}'), // 评论信息
  35. Text(
  36. '${DateTime.fromMillisecondsSinceEpoch(_detail.goodComments[index].discussTime)}'
  37. .split('.')
  38. .first), // 评论时间
  39. ],
  40. ),
  41. ),
  42. childCount: _detail.goodComments.length),
  43. itemExtent: 80.0),
  44. SliverToBoxAdapter(
  45. child: Image.network(_detail.advertesPicture.PICTURE_ADDRESS))
  46. ],
  47. );
  48. });
  49. }
  50. }