check null safety

This commit is contained in:
tzw
2021-09-10 14:27:38 +06:30
parent a144c945b6
commit 7670779b03
57 changed files with 620 additions and 626 deletions

View File

@@ -20,8 +20,8 @@ Future<dynamic> requestAPI(
String path,
method, {
dynamic payload,
String token,
String url,
String? token,
String? url,
}) async {
DevInfo devInfo = await DevInfo.getDevInfo();
@@ -33,7 +33,7 @@ Future<dynamic> requestAPI(
headers["Token"] = token;
}
if (devInfo != null && devInfo.deviceID != null && deviceName != null) {
headers["Device"] = devInfo.deviceID + ":" + deviceName;
headers["Device"] = devInfo.deviceID??"" + ":" + deviceName;
}
headers["Project-ID"] = Config.instance.reportProjectID;
@@ -66,7 +66,7 @@ Future<dynamic> requestAPI(
// request makes http request
// if token is null
Future<dynamic> requestDownloadAPI(String path, method,
{dynamic payload, String token, String url, String filePath}) async {
{dynamic payload, String? token, String? url, String? filePath}) async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
String deviceName = "${androidInfo.model}(${androidInfo.id})";
@@ -81,7 +81,7 @@ Future<dynamic> requestDownloadAPI(String path, method,
log.info("Path:$baseUrl$path");
HttpClient client = new HttpClient();
var _downloadData = StringBuffer();
var fileSave = new File(filePath);
var fileSave = new File(filePath!);
var request = await client.getUrl(Uri.parse("$baseUrl$path"));
request.headers.set("Project-ID", Config.instance.reportProjectID);
request.headers
@@ -108,7 +108,7 @@ Future<dynamic> requestDownloadAPI(String path, method,
// request makes http request
// if token is null
Future<dynamic> requestDownloadPDFAPI(String path, method,
{dynamic payload, String token, String url, String filePath}) async {
{dynamic payload, String? token, String? url, String? filePath}) async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
String deviceName = "${androidInfo.model}(${androidInfo.id})";
@@ -123,7 +123,7 @@ Future<dynamic> requestDownloadPDFAPI(String path, method,
log.info("Path:$baseUrl$path");
HttpClient client = new HttpClient();
// var _downloadData = StringBuffer();
var fileSave = new File(filePath);
var fileSave = new File(filePath!);
var request = await client.getUrl(Uri.parse("$baseUrl$path"));
request.headers.set("Project-ID", Config.instance.reportProjectID);
if (token != null) {
@@ -135,7 +135,7 @@ Future<dynamic> requestDownloadPDFAPI(String path, method,
request.headers.set("payload", escapePayload);
var response = await request.close();
print("headers:${response.headers}");
var _downloadData = List<int>();
List<int> _downloadData = [];
response.listen((d) => _downloadData.addAll(d), onDone: () {
fileSave.writeAsBytes(_downloadData);
@@ -155,10 +155,10 @@ typedef OnDownloadDone(File file);
// if token is null
Future<dynamic> requestDownload(String path, method,
{dynamic payload,
String token,
String url,
String filePath,
OnDownloadDone onDownloadDone}) async {
required String token,
required String url,
required String filePath,
OnDownloadDone? onDownloadDone}) async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
String deviceName = "${androidInfo.model}(${androidInfo.id})";
@@ -188,7 +188,7 @@ Future<dynamic> requestDownload(String path, method,
// request.write(escapePayload);
var response = await request.close();
print("headers:${response.headers}");
var _downloadData = List<int>();
List<int> _downloadData = [];
var cd = response.headers.value("content-disposition");
String fileName = "download.csv";
if (cd != null && cd.contains("filename=")) {