|
- import 'package:flutter/material.dart';
- import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_item_single.dart';
- import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart';
- import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart';
- import 'package:zhiying_comm/util/net_util.dart';
-
- class TestPage extends StatefulWidget {
- @override
- _TestPageState createState() => _TestPageState();
- }
-
- class _TestPageState extends State<TestPage> {
- List<HomeGoodsModel> _goods;
- HomeGoodsStyleModel _styleModel;
-
- @override
- void initState() {
- NetUtil.request('/api/v1/rec/featured?page=3', method: NetMethod.GET,
- onSuccess: (data) {
- List goods = data['good'];
- _styleModel = HomeGoodsStyleModel(
- listColumn: '1',
- // recommendList,
- providerNameColor: '#ffffff',
- providerNameBackgroundColor: '#ff4242',
- shopNameColor: '#ffffff',
- shopIcon: '',
- couponFontColor: '#ffffff',
- couponBgColor: '#ff4242',
- commissionFontColor: '#ffffff',
- commissionBgColor: '#ff4242',
- marketPriceColor: '#ffffff',
- currentPriceColor: '#ff4242',
- );
- _goods = goods.map((e) {
- return HomeGoodsModel.fromJson(Map<String, dynamic>.from(e));
- }).toList();
- setState(() {});
- });
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text('测试'),
- ),
- body: CustomScrollView(
- slivers: <Widget>[
- SliverFixedExtentList(
- itemExtent: 200.0,
- delegate: new SliverChildBuilderDelegate(
- (BuildContext context, int index) {
- //创建列表项
- return HomeGoodsItemSingle(
- _goods[index % _goods.length], _styleModel);
- },
- childCount: (_goods?.length ?? 0) * 2000, //50个列表项
- ),
- ),
- // SliverToBoxAdapter(
- // child: ListView.builder(
- // shrinkWrap: true,
- // physics: NeverScrollableScrollPhysics(),
- // itemCount: (_goods?.length ?? 0) * 20,
- // itemBuilder: (context, index) {
- // return HomeGoodsItemSingle(
- // _goods[index % _goods.length], _styleModel);
- // }),
- // )
- ],
- ));
- }
- }
|