Skip to content

Commit

Permalink
docs(example): fix crash when trying to downscale image on isolate
Browse files Browse the repository at this point in the history
  • Loading branch information
benthillerkus committed May 16, 2022
1 parent 03ca002 commit dacf5ae
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
19 changes: 13 additions & 6 deletions example/select_image/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ class _HomeScreenState extends State<HomeScreen> {
iconSource = TrayIconImageDelegate.fromPath(path: path);
break;
case "png":
var resized = await compute((String path) {
var resized = await compute((Tuple<String, Size> arg) {
final path = arg.first;
final size = arg.second;
var org = img.decodePng(File(path).readAsBytesSync());
final height = TrayIcon.preferredImageSize.height.toInt();
final width = TrayIcon.preferredImageSize.width.toInt();
var resized = img.copyResize(org!,
height: height,
width: width,
height: size.height.toInt(),
width: size.width.toInt(),
interpolation: img.Interpolation.average);
return resized.getBytes().buffer;
}, path);
}, Tuple(path, TrayIcon.preferredImageSize));

iconSource = TrayIconImageDelegate.fromBytes(resized);
break;
Expand Down Expand Up @@ -157,3 +157,10 @@ class _HomeScreenState extends State<HomeScreen> {
_icon.show();
}
}

class Tuple<A, B> {
final A first;
final B second;

const Tuple(this.first, this.second);
}
18 changes: 9 additions & 9 deletions example/select_image/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
crypto:
dependency: transitive
description:
Expand All @@ -70,7 +70,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -127,7 +127,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -155,7 +155,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -178,7 +178,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
petitparser:
dependency: transitive
description:
Expand All @@ -204,7 +204,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -239,7 +239,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
version: "0.4.9"
typed_data:
dependency: transitive
description:
Expand All @@ -253,7 +253,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
win32:
dependency: transitive
description:
Expand All @@ -269,5 +269,5 @@ packages:
source: hosted
version: "5.3.1"
sdks:
dart: ">=2.16.2 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.5.0"
8 changes: 8 additions & 0 deletions example/select_image/windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
native_context_menu
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
Expand All @@ -15,3 +18,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

0 comments on commit dacf5ae

Please sign in to comment.