Я использую Flutter и Firebase Storage для приложения. Я попытался создать функцию, чтобы узнать, существует ли файл или нет:
Future<bool> exists(String path) async {
bool _exists;
StorageReference storageReference = FirebaseStorage.instance.ref().child(path);
try {
await storageReference.getDownloadURL();
_exists = true;
} catch (exception) {
_exists = false;
}
return _exists;
}
Он работает, но когда файл не существует, он все равно регистрирует ошибку:
I/System.out(12012): (HTTPLog)-Static: isSBSettingEnabled false
E/StorageException(12012): StorageException has occurred.
E/StorageException(12012): Object does not exist at location.
E/StorageException(12012): Code: -13010 HttpResult: 404
E/StorageException(12012): { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
E/StorageException(12012): java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException(12012): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException(12012): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException(12012): at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@17.0.0:74)
E/StorageException(12012): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/StorageException(12012): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/StorageException(12012): at java.lang.Thread.run(Thread.java:764)
Из-за этого консоль теперь заполнена этими строками, и стало очень трудно отладить что-либо еще ...
Как я могу скрыть эти строки?
Спасибо!