xuelongqy / flutter_easy_refresh

A flutter widget that provides pull-down refresh and pull-up load.
https://xuelongqy.github.io/flutter_easy_refresh/
MIT License
3.84k stars 628 forks source link

使用paging时,在itemBuilder中传输参数问题。 #762

Closed YuQi9797 closed 6 months ago

YuQi9797 commented 9 months ago

作者您好,我在按照example中的'paging_page.dart'进行修改。

class _PagingPageState extends State<PagingPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Paging example'.tr),
      ),
      body: CustomPaging(
        itemBuilder: <MyType>(context, index, item) {
          return const MyItem(item);
        },
      ),
    );
  }
}

此处在itemBuilder中,我返回的是自己的Itme布局,同时传入自定义MyType类Item。但出现 The argument type 'MyType' can't be assigned to the parameter type 'MyType'.问题, 就问该如何解决? 谢谢

YuQi9797 commented 9 months ago

找到问题了, ItemType不应该去动它。 直接对自己的item进行类型转换。虽然不知道为什么...

itemBuilder: <ItemType>(context, index, item) {
            return LeaveItem(item as MyType);
}
xuelongqy commented 6 months ago

3.3.4添加了类型推断。如还有问题,请重新开启此issue