cleanup code

This commit is contained in:
tzw
2024-01-23 16:28:08 +06:30
parent a1e87cdbf6
commit f3f75a80c6
96 changed files with 232 additions and 439 deletions

View File

@@ -27,7 +27,7 @@ Future<dynamic> requestAPI(String path, method,
if (token != null) {
headers["Token"] = token;
}
if (devInfo != null && devInfo.deviceID != null && deviceName != null) {
if (devInfo.deviceID != null) {
headers["Device"] = devInfo.deviceID ?? "" + ":" + deviceName;
}
headers["Project-ID"] = Config.instance.reportProjectID;
@@ -148,8 +148,8 @@ typedef OnDownloadDone(File file);
// if token is null
Future<dynamic> requestDownload(String path, method,
{dynamic payload,
required String token,
required String url,
required String? token,
required String? url,
required String filePath,
OnDownloadDone? onDownloadDone}) async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
@@ -187,7 +187,7 @@ Future<dynamic> requestDownload(String path, method,
fileName = cd.substring(cd.indexOf("=") + 1);
}
var file = filePath + "/" + fileName;
// var file = filePath + "/" + fileName;
var fileSave = new File(filePath + "/" + fileName);
response.listen((d) => _downloadData.addAll(d), onDone: () async {
await fileSave.writeAsBytes(_downloadData);

View File

@@ -62,7 +62,7 @@ Future<String> uploadStorage(String path, File? file,
}
Future<void> deleteStorageFromUrls(List<String?> urls) async {
if (urls == null) return;
if (urls.isEmpty) return;
for (int i = 0; i < urls.length; i++) {
if (urls[i] == null) return;
await deleteStorageFromUrl(urls[i]!);

View File

@@ -51,7 +51,7 @@ class NetworkConnectivity {
}
}
if (_controller != null && !_controller.isClosed)
if (!_controller.isClosed)
_controller.sink.add({"isOnline": isOnline});
}