错误在两个区域引发(并且应用程序冻结(当应用程序最小化时,当点击手机后退按钮时,或者当另一个应用程序在颤振应用程序之上运行时。颤振版本:1.20.2(以前的版本没有这个问题):这两个功能是:
@override
void initState() {
super.initState();
getItems();
}
getItems() async {
initClearVisibility();
initFilters();
setState(() {
loadingItems = true;
Visibility(visible: true, child: CircularProgressIndicator());
});
QuerySnapshot querySnapshot = await query.get();
items = querySnapshot.docs;
lastDocument = querySnapshot.docs[querySnapshot.docs.length - 1];
setState(() {
loadingItems = false;
Visibility(visible: false, child: CircularProgressIndicator());
});
}
initClearVisibility() {
if (Str.filterSelectCategory != Str.CATEGORY) {
clearCategoryVisible = true;
allCategoriesVisible = false;
categoryValue = Str.filterSelectCategory;
setState(() {});
}
}
initFilters() async {
filterDefaultItems();
}
filterDefaultItems() async {
query = _firestore
.collection(Str.ITEMS)
.where(Str.IS_ITEM_SOLD, …Run Code Online (Sandbox Code Playgroud) PlatformException (PlatformException(Share callback error, prior share-sheet did not call back, did you await it就我而言,使用以下代码时出现以下错误:
final XFile file = XFile(path);\nawait Share.shareXFiles([file],\nRun Code Online (Sandbox Code Playgroud)\n但如果我使用如下所示的已弃用方法(传递列表),则图像共享效果完美:
\nawait Share.shareFiles([path],\nsubject: subject,\ntext: text,\nsharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);\nRun Code Online (Sandbox Code Playgroud)\nshareFiles被标记为已弃用,但工作正常,在遵循文档并使用时shareXFiles,会抛出平台异常错误:
我的环境:
\nFlutter 3.7.10 \xe2\x80\xa2 通道稳定 \xe2\x80\xa2 https://github.com/flutter/flutter.git \nFramework \xe2\x80\xa2 修订版 4b12645012(9 天前) \xe2\x80 \xa2 2023-04-03 17:46:48 -0700\n引擎 \xe2\x80\xa2 修订版 ec975089ac\n工具 \xe2\x80\xa2 Dart 2.19.6 \xe2\x80\xa2 DevTools 2.20.1
\n我有一种方法可以检查是否设置了当前用户位置,如果没有,打开一个带有两个按钮的警报对话框:取消和更新配置文件。更新配置文件按钮的 onPressed 导航到带有更新用户位置的表单的第二个屏幕。问题是:如果用户单击“更新”按钮并更新位置,则单击“后退”按钮时,将显示第一页,但警报对话框仍处于打开状态。期望:在关闭后退按钮和更新位置时,后退按钮打开第一个屏幕并刷新整个页面,获取新的位置设置。见代码:FIRST SCREEN (HOME SCREEN) @override void initState() { super.initState(); 获取用户详细信息();}
updateProfileLocationPrompt(BuildContext context) {
Widget cancelButton = FlatButton(
child: Text("Cancel",
),
onPressed: () {
Navigator.of(context).pop(true);
},
);
Widget updateProfileButton = FlatButton(
child: Text("Update",
),
onPressed: () {
Navigator.of(context)
.push(new MaterialPageRoute(builder: (context) => SettingsScreen()));
},
);
AlertDialog alert = AlertDialog(
title: Text("Update location",
),
content: Text(
"Please Update you location",
),
actions: [
cancelButton,
updateProfileButton,
],
);
// show the dialog
showDialog(
context: context,
builder: (BuildContext context) {
return alert; …Run Code Online (Sandbox Code Playgroud)