fluttercandies/loading_more_list

部分场景下无法正常使用,有复现demo

mdddj opened this issue · 2 comments

mdddj commented

先上例子,不能触发loadData加载数据

import 'package:flutter/material.dart';
import 'package:loading_more_list/loading_more_list.dart';


class BugPage extends StatelessWidget {

  const BugPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverList(delegate: SliverChildBuilderDelegate((context, index) {
            return const Text("---");
          },childCount: 2)),
          const Bug()
        ],
      ),
    );
  }
}


class BugRespository extends LoadingMoreBase<String>{
  @override
  Future<bool> loadData([bool isloadMoreAction = false]) async  {
    print("加载数据");
    await Future.delayed(const Duration(seconds: 1));
    final datas = List.generate(20, (index) => 'index: ${length+index}');
    return true;
  }

}

class Bug extends StatelessWidget {
  const Bug({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print('build..');
    return LoadingMoreSliverList(SliverListConfig<String>(
      itemBuilder: (c,item,index)=>Text(item),
      sourceList: BugRespository()
    ));
  }
}

看一下demo ,好不好