| var token = await pref.getString(DATA_CONST.TOKEN_KEY); | var token = await pref.getString(DATA_CONST.TOKEN_KEY); | ||||
| options.headers["Authorization"] = "Bearer $token"; | options.headers["Authorization"] = "Bearer $token"; | ||||
| options.receiveTimeout = 20000; | options.receiveTimeout = 20000; | ||||
| log("onRequest: ${options.uri}\n" | |||||
| "data=${options.data}\n" | |||||
| "method=${options.method}\n" | |||||
| "headers=${options.headers}\n" | |||||
| "queryParameters=${options.queryParameters}"); | |||||
| // log("onRequest: ${options.uri}\n" | |||||
| // "data=${options.data}\n" | |||||
| // "method=${options.method}\n" | |||||
| // "headers=${options.headers}\n" | |||||
| // "queryParameters=${options.queryParameters}"); | |||||
| return options; | return options; | ||||
| } | } | ||||
| final dir = await path_provider.getTemporaryDirectory(); | final dir = await path_provider.getTemporaryDirectory(); | ||||
| final fileName = path.basenameWithoutExtension(file.path); | final fileName = path.basenameWithoutExtension(file.path); | ||||
| final targetPath = dir.absolute.path + "/$fileName.jpg"; | final targetPath = dir.absolute.path + "/$fileName.jpg"; | ||||
| print('before: ' + file.lengthSync().toString()); | |||||
| final imgFile = await compressAndGetFile(file, targetPath); | final imgFile = await compressAndGetFile(file, targetPath); | ||||
| print('after: ' + imgFile.lengthSync().toString()); | |||||
| return imgFile; | return imgFile; | ||||
| } | } | ||||
| static Future<File> compressAndGetFile(File file, String targetPath) async { | static Future<File> compressAndGetFile(File file, String targetPath) async { | ||||
| final result = await FlutterImageCompress.compressAndGetFile( | final result = await FlutterImageCompress.compressAndGetFile( | ||||
| file.absolute.path, targetPath, | file.absolute.path, targetPath, | ||||
| minWidth: 1024, minHeight: 1024); | |||||
| quality: 5, minWidth: 1280, minHeight: 720); | |||||
| return result; | return result; | ||||
| } | } | ||||
| } | } |
| } | } | ||||
| if (event is OnRefresh) { | if (event is OnRefresh) { | ||||
| try { | try { | ||||
| print("loading..."); | |||||
| final response = await repository.getEnvironmentParameters( | final response = await repository.getEnvironmentParameters( | ||||
| cropId: event.cropId, page: 0, size: pageSize); | cropId: event.cropId, page: 0, size: pageSize); | ||||
| List<EnvironmentParameter> updatedList = List<EnvironmentParameter>(); | List<EnvironmentParameter> updatedList = List<EnvironmentParameter>(); |