我有一个StreamBuilder
正在从我的 bloc 组件中获取数据。
但是,它一直拒绝我的类型注释AsyncSnapshot<List<int>> snapshot
,并且只接受 dynamic 作为 type AsyncSnapshot<List<dynamic>> snapshot
。然而,在我看过的例子中,它们确实有没有抱怨的类型注释。
这是我的流创建。
Widget buildList(StoriesBloc bloc) {
return StreamBuilder(
stream: bloc.topIds,
builder: (BuildContext context, AsyncSnapshot<List<int>> snapshot) {
if (!snapshot.hasData) {
return Text("Still Waiting for Ids to fetch");
}
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, int index) {
return Text('${snapshot.data[index]}');
},
);
},
);
}
我可能做错了什么?