Browse Source

compressed image to 5%

master
daivph 5 years ago
parent
commit
f3d94c4f5d
3 changed files with 8 additions and 7 deletions
  1. +5
    -5
      lib/data/api/dio_provider.dart
  2. +3
    -1
      lib/presentation/screens/actions/util_action.dart
  3. +0
    -1
      lib/presentation/screens/plot_detail/bloc/plot_parameter_bloc.dart

+ 5
- 5
lib/data/api/dio_provider.dart View File

@@ -26,11 +26,11 @@ class HttpLogInterceptor extends InterceptorsWrapper {
var token = await pref.getString(DATA_CONST.TOKEN_KEY);
options.headers["Authorization"] = "Bearer $token";
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;
}


+ 3
- 1
lib/presentation/screens/actions/util_action.dart View File

@@ -76,14 +76,16 @@ class UtilAction {
final dir = await path_provider.getTemporaryDirectory();
final fileName = path.basenameWithoutExtension(file.path);
final targetPath = dir.absolute.path + "/$fileName.jpg";
print('before: ' + file.lengthSync().toString());
final imgFile = await compressAndGetFile(file, targetPath);
print('after: ' + imgFile.lengthSync().toString());
return imgFile;
}

static Future<File> compressAndGetFile(File file, String targetPath) async {
final result = await FlutterImageCompress.compressAndGetFile(
file.absolute.path, targetPath,
minWidth: 1024, minHeight: 1024);
quality: 5, minWidth: 1280, minHeight: 720);
return result;
}
}

+ 0
- 1
lib/presentation/screens/plot_detail/bloc/plot_parameter_bloc.dart View File

@@ -54,7 +54,6 @@ class PlotParameterBloc extends Bloc<PlotParameterEvent, PlotParameterState> {
}
if (event is OnRefresh) {
try {
print("loading...");
final response = await repository.getEnvironmentParameters(
cropId: event.cropId, page: 0, size: pageSize);
List<EnvironmentParameter> updatedList = List<EnvironmentParameter>();

Loading…
Cancel
Save