基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

76 lines
2.5 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_item_single.dart';
  3. import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart';
  4. import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart';
  5. import 'package:zhiying_comm/util/net_util.dart';
  6. class TestPage extends StatefulWidget {
  7. @override
  8. _TestPageState createState() => _TestPageState();
  9. }
  10. class _TestPageState extends State<TestPage> {
  11. List<HomeGoodsModel> _goods;
  12. HomeGoodsStyleModel _styleModel;
  13. @override
  14. void initState() {
  15. NetUtil.request('/api/v1/rec/featured?page=3', method: NetMethod.GET,
  16. onSuccess: (data) {
  17. List goods = data['good'];
  18. _styleModel = HomeGoodsStyleModel(
  19. listColumn: '1',
  20. // recommendList,
  21. providerNameColor: '#ffffff',
  22. providerNameBackgroundColor: '#ff4242',
  23. shopNameColor: '#ffffff',
  24. shopIcon: '',
  25. couponFontColor: '#ffffff',
  26. couponBgColor: '#ff4242',
  27. commissionFontColor: '#ffffff',
  28. commissionBgColor: '#ff4242',
  29. marketPriceColor: '#ffffff',
  30. currentPriceColor: '#ff4242',
  31. );
  32. _goods = goods.map((e) {
  33. return HomeGoodsModel.fromJson(Map<String, dynamic>.from(e));
  34. }).toList();
  35. setState(() {});
  36. });
  37. super.initState();
  38. }
  39. @override
  40. Widget build(BuildContext context) {
  41. return Scaffold(
  42. appBar: AppBar(
  43. title: Text('测试'),
  44. ),
  45. body: CustomScrollView(
  46. slivers: <Widget>[
  47. SliverFixedExtentList(
  48. itemExtent: 200.0,
  49. delegate: new SliverChildBuilderDelegate(
  50. (BuildContext context, int index) {
  51. //创建列表项
  52. return HomeGoodsItemSingle(
  53. _goods[index % _goods.length], _styleModel);
  54. },
  55. childCount: (_goods?.length ?? 0) * 2000, //50个列表项
  56. ),
  57. ),
  58. // SliverToBoxAdapter(
  59. // child: ListView.builder(
  60. // shrinkWrap: true,
  61. // physics: NeverScrollableScrollPhysics(),
  62. // itemCount: (_goods?.length ?? 0) * 20,
  63. // itemBuilder: (context, index) {
  64. // return HomeGoodsItemSingle(
  65. // _goods[index % _goods.length], _styleModel);
  66. // }),
  67. // )
  68. ],
  69. ));
  70. }
  71. }