我一直在努力将更新的数据从一个小部件推送到另一个小部件。当我有两个状态小部件并且在父状态小部件中更新数据但在子状态小部件中未更新数据时,会发生此问题。使用冻结的程序包时会发生此错误,但如果不使用该程序包,也会发生此错误。
到目前为止,我还没有找到任何可以解决此问题的方法。
下面是一个示例:
第一个有状态小部件:
Lucieta Spinelli
Bryn Mawr College
8 9 8 7 8 8 8 2.5
7 8 7 6 7 7 6 3.7
8 7 6 7 7 6 8 3.2
LiPing Sun
Rutgers University
6.5 5 9.5 7.5 8 8.5 7 2.3
7 9 7.5 9 8.5 6.5 8 2.6
6 4 5 9 7 8 6 3.0
Greg McEntire
University of Southern California
9 8 8.5 9.5 9 9.5 7 2.3
9 7 8 8 7.5 8.5 7.5 2.6
8 8 8 8 8 8 8 3.4
Shiva Vadaparthy
Northwestern University
9 8 9.5 9.5 7.5 8 8.5 3.0
8 9 8.5 7.5 9 8.5 8 3.6
7.5 9 8 7 8.5 8 7 4.1
Elizabeth Bennet
Oxford University
7 8 9 8 7 7 8 2.4
8 8 6 7 9 7 8 2.7
8 7 8 6 9 8 9 3.0
Sofia Berrios
Universidad Simon Bolivar
8.5 7.5 9.5 9 7 8.5 8 2.4
8 7 8 9 8 6 7 3.0
7 5.5 6.5 7 5 6.5 7 3.6
Amir Majid
Reed College
4 5 6 5 3 5 7 2.8
7 6 7 8 7 9 8 2.9
8 9 7 9 8.5 8 9 3.4
James Pajuio
University of Pennsylvania
8 7 8 9 8 6 7 2.8
7.5 9 8 7 8.5 8 7 3.0
7.5 9 8 7 8.5 8 7 4.3
Sharon Lewis
Howard University
8 9 9.5 9 8.5 8 9 2.7
4 5 5.5 7 6.5 4.5 5 3.2
8 7 8 9 8 8 7 4.0
Divya Patel
Temple University
7 9 7.5 9 8.5 6.5 8 2.1
8 7 8 6 9 8 9 2.3
3.5 5.5 4 5 3 4 4.5 4.3
Guo Zhang
Portland State University
5 6 5.5 7 6.5 7 5.5 6 3.0
8 7 8.5 9 7.5 8.5 8 3.2
9 8 9.5 8.5 9 8.5 9.5 4.1
Tomasz Wojaczyk
Tufts University
8 8 7 8 7 8 7 2.6
5 4 5 6 7 5 5 2.9
8 6 6 7 8 7 6 3.6
第二状态小部件:
class FirstWidget extends StatefulWidget {
@override
_FirstWidgetState createState() => _FirstWidgetState();
}
class _FirstWidgetState extends State<FirstWidget> {
ItemBloc _itemBloc = getit<ItemBloc>();
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
elevation: Mquery.width(context, 2.5),
backgroundColor: Colors.black
title: Text(
'First stateful widget',
style: TextStyle(fontSize: 17),
),
centerTitle: true,
),
body: BlocBuilder<ItemsBloc,ItemsState>(
cubit: _itemsBloc,
builder: (BuildContext context,ItemState state) {
return state.when(
initial: () => Container(),
loading: () => Center(child: CustomLoader()),
success: (_items) {
return AnotherStatefulWidget(
items: _items,
...
);
},
);
},
));
},
);
);
}
}
我将非常感谢您的帮助!
感谢您的时间,