我知道这个问题已经被问过几次,我已经尝试过建议的方法,即将“返回”放在正确的位置。我也按照控制台中的说明尝试添加一个空容器,但结果是我的屏幕变黑了。所以这是我的代码:
class SettingsPage extends StatefulWidget {
@override
_SettingsPageState createState() => _SettingsPageState();
}
class _SettingsPageState extends State<SettingsPage> {
@override
Widget build(BuildContext context) {
bool isSystemSelected;
final stream = AllowedCallInheritedWidget.of(context).allowedCallStream;
return StreamBuilder<String>(
stream: stream,
builder: (context, snapshot) {
if (snapshot.data.toString().contains('PRIORITY_SENDERS_CONTACTS')) {
isSystemSelected = true;
return AlertDialog(
backgroundColor: isSystemSelected ? Colors.blueGrey : Colors.amber,
title: Text(snapshot.data),
);
} else if (snapshot.data
.toString()
.contains('PRIORITY_SENDERS_STARRED')) {
isSystemSelected = true;
return AlertDialog(
backgroundColor: isSystemSelected ? Colors.blueGrey : Colors.amber,
title: Text(snapshot.data),
);
} else if (snapshot.data.toString().contains('PRIORITY_SENDERS_ANY')) {
isSystemSelected = true;
return AlertDialog(
backgroundColor: isSystemSelected ? Colors.blueGrey : Colors.amber,
title: Text(snapshot.data),
);
}
},
);
}
}
我想做的是实时更新android系统的变化。谢谢你的帮助!
编辑:我应该添加“有问题的小部件是:StreamBuilder”