Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
YuQi9797 opened this issue Sep 14, 2023 · 2 comments
Closed

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

YuQi9797 opened this issue Sep 14, 2023 · 2 comments

Comments

@YuQi9797
Copy link

YuQi9797 commented Sep 14, 2023

作者您好,我在按照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 YuQi9797 changed the title 如何在启动时刷新后,发现没有数据时在ListView上显示提示信息? 使用paging时,在itemBuilder中传输参数问题。 Sep 15, 2023
@YuQi9797 YuQi9797 reopened this Sep 15, 2023
@YuQi9797
Copy link
Author

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

itemBuilder: <ItemType>(context, index, item) {
            return LeaveItem(item as MyType);
}

@xuelongqy
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants