我有一个CupertinoSegmentedControl
,它使我可以根据所选择的索引在不同的信息下方显示:
class LoadData extends StatefulWidget {
final DocumentSnapshot data;
final FirebaseUser user;
const LoadData({this.data, this.user});
@override
_LoadDataState createState() => _LoadDataState();
}
class _LoadDataState extends State<LoadData> {
final Map<int, Widget> logoWidgets = const <int, Widget>{
0: Text('Ambos'),
1: Text('Admin'),
2: Text('Junta'),
};
int sharedValue = 0;
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: SafeArea(
child: new Scaffold(
body: Column(
children: <Widget>[
const Padding(
padding: EdgeInsets.only(top:60.0),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.99,
child: CupertinoSegmentedControl<int>(
children: logoWidgets,
onValueChanged: (int val) {
setState(() {
sharedValue = val;
});
},
groupValue: sharedValue,
),
),
Expanded(
child: Container(
child: filtrado(widget.data, widget.user, sharedValue),
)),
],
),
),
));
}
Stream<QuerySnapshot> filtro(data, user, val) {
print(val);
if (val == 0)
return Firestore.instance
.collection(data3)
.snapshots()
if (val == 1)
return Firestore.instance
.collection(data3)
.snapshots()
if (val == 2)
return Firestore.instance
.collection(data3)
.snapshots()
}
Widget filtrado(data, user, val) {
return StreamBuilder(
stream: filtro(data, user, val),
builder: ...
我遇到的问题是内存已满或什么东西了,CupertinoSegmentedControl
冻结而没有打印任何内容。但这只会冻结实际的屏幕。如果我返回上一个屏幕,它将解冻。
我该如何解决?
编辑: 我发现冻结的唯一东西是实际的CupertinoSegmentedControl,所以当我单击它时,它不会在选项周围变化。