Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ There are several ways to use the library api.
```dart

// 1. compress file and get Uint8List
Future<Uint8List> testCompressFile(File file) async {
Future<Uint8List?> testCompressFile(File file) async {
var result = await FlutterImageCompress.compressWithFile(
file.absolute.path,
minWidth: 2300,
Expand All @@ -101,26 +101,31 @@ There are several ways to use the library api.
rotate: 90,
);
print(file.lengthSync());
print(result.length);
if (result != null) {
print(result.length);
}
return result;
}

// 2. compress file and get file.
Future<File> testCompressAndGetFile(File file, String targetPath) async {
Future<File?> testCompressAndGetFile(File file, String targetPath) async {
var result = await FlutterImageCompress.compressAndGetFile(
file.absolute.path, targetPath,
quality: 88,
rotate: 180,
);

print(file.lengthSync());
print(result.lengthSync());
if (result != null) {
print(await result.length());
return File(result.path);
}

return result;
}

// 3. compress asset and get Uint8List.
Future<Uint8List> testCompressAsset(String assetName) async {
Future<Uint8List?> testCompressAsset(String assetName) async {
var list = await FlutterImageCompress.compressAssetImage(
assetName,
minHeight: 1920,
Expand Down