未处理的异常:'package:firebase_storage/src/storage_reference.dart':失败的断言:第62行pos 12:'file.existsSync()':不正确 [英] Unhandled Exception: 'package:firebase_storage/src/storage_reference.dart': Failed assertion: line 62 pos 12: 'file.existsSync()': is not true
问题描述
未处理的异常:'package:firebase_storage/src/storage_reference.dart':断言失败:第62行pos 12:'file.existsSync()':不正确.
Unhandled Exception: 'package:firebase_storage/src/storage_reference.dart': Failed assertion: line 62 pos 12: 'file.existsSync()': is not true.
在导航中,"package:firebase_storage/src/storage_reference.dart"中的代码为:
On naviagtion, code in 'package:firebase_storage/src/storage_reference.dart' is :
assert(file.existsSync());
final _StorageFileUploadTask task =
_StorageFileUploadTask._(file, _firebaseStorage, this, metadata);
task._start();
return task;
}
将图像上载到Firebase存储的代码:
Code of uplading image to firebase storage:
void _selectImage(Future<File> pickImage, int imageNumber) async {
File tempImg = await pickImage;
switch (imageNumber) {
case 1:
setState(() => _image1 = tempImg);
break;
case 2:
setState(() => _image2 = tempImg);
break;
case 3:
setState(() => _image3 = tempImg);
break;
case 4:
setState(() => _image4 = tempImg);
break;
}
}
Widget _displayChild1() {
if (_image1 == null) {
return Padding(
padding: const EdgeInsets.fromLTRB(14, 70, 14, 70),
child: new Icon(
Icons.add,
color: Colors.grey.withOpacity(1),
),
);
} else {
return Image.file(
_image1,
fit: BoxFit.fill,
width: double.infinity,
);
}
}
String imageUrl1;
String imageUrl2;
String imageUrl3;
String imageUrl4;
// String imageUrl3;
final FirebaseStorage storage = FirebaseStorage.instance;
final String picture1 = "1${DateTime.now().millisecondsSinceEpoch.toString()}.jpg";
StorageUploadTask task1 = storage.ref().child(picture1).putFile(_image1);
final String picture2 = "2${DateTime.now().millisecondsSinceEpoch.toString()}.jpg";
StorageUploadTask task2 = storage.ref().child(picture2).putFile(_image2);
final String picture3 = "3${DateTime.now().millisecondsSinceEpoch.toString()}.jpg";
StorageUploadTask task3 = storage.ref().child(picture3).putFile(_image3);
final String picture4 = "4${DateTime.now().millisecondsSinceEpoch.toString()}.jpg";
StorageUploadTask task4 = storage.ref().child(picture4).putFile(_image4);
StorageTaskSnapshot snapshot1 =
await task1.onComplete.then((sanapshot) => sanapshot);
StorageTaskSnapshot snapshot2 =
await task2.onComplete.then((sanapshot) => sanapshot);
StorageTaskSnapshot snapshot3 =
await task3.onComplete.then((sanapshot) => sanapshot);
task4.onComplete.then((snapshot4) async {
imageUrl1 = await snapshot1.ref.getDownloadURL();
imageUrl2 = await snapshot2.ref.getDownloadURL();
imageUrl3 = await snapshot3.ref.getDownloadURL();
imageUrl4 = await snapshot4.ref.getDownloadURL();
uploadProduct(
images: imageUrl1,
images2: imageUrl2,
images3: imageUrl3,
images4: imageUrl4,
);
在将图像上传到Firebase存储之前发生错误. 有什么办法吗?
An error occurs before uploading images to firebase storage. Any solutions?
价格货币:2美元(PayPal)
Price money: $2 (PayPal)
推荐答案
这可能是干净的问题,或者我只是删除了应用程序并重新安装了它:) 希望对您有帮助.
This may be a problem of flutter clean or i just did delete app and re-install it again :) Hope it help.
这篇关于未处理的异常:'package:firebase_storage/src/storage_reference.dart':失败的断言:第62行pos 12:'file.existsSync()':不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!