我正在尝试在自定义滚动视图中实现两个Sliver小部件,并且一旦向下滚动并返回列表中的项目,我将面临sliverbuilderlist中传递的数据状态问题处理,因此我得到一个错误。仅当我同时使用两个或多个条子小部件时,才发生这种情况,条子列表本身就可以了, 现在,我正在实现带有两个标签的可折叠sliverappbar 我通过了sliverlistbuilder两个选项卡,几秒钟后再次上下滚动时出现错误,请帮助我了解问题
关于此问题,我什么都找不到,我尝试将包含int sliverlist的Widget更改为有状态的Widget,并尝试在sliver参数之前调用set state,但这没有用
feed [i]从提供者Feed中绘制对象
class FeedItemScreen extends StatefulWidget {
@override
_ FeedItemScreenState createState() => _FeedItemScreenState();}
class _FeedItemScreenState extends State<FeedItemScreen> {
@override Widget build(BuildContext context) {
final feedData = Provider.of<Feed>(context);
final feed = feedData.items;
setState(() {});
return CustomScrollView(
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(context, i) => ChangeNotifierProvider(
builder: (ctx) => feed[i],
child: FeedsItem(),
),
childCount: feed.length,
),
),
],
);
} }
inside Defaulttabcontroller : I'm passing FeedScreen(), which builds the list to one of the tabs
body: TabBarView(
children: <Widget>[
NotificationScreen(),
FeedScreen(),
],
)),
/flutter ( 5092): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 5092): The following assertion was thrown building NotificationListener<KeepAliveNotification>:
I/flutter ( 5092): A FeedItem was used after being disposed.
I/flutter ( 5092): Once you have called dispose() on a FeedItem, it can no longer be used.
FeedItem是我的数据传递到的类,这是我得到的错误,当在单个视口中使用多个条子时,我也遇到了相同的错误。