fix: resize images in a separate isolate
This commit is contained in:
parent
e14f3354e5
commit
a113f99135
6 changed files with 131 additions and 113 deletions
12
lib/utils/run_in_background.dart
Normal file
12
lib/utils/run_in_background.dart
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import 'package:isolate/isolate.dart';
|
||||
import 'dart:async';
|
||||
|
||||
Future<T> runInBackground<T, U>(
|
||||
FutureOr<T> Function(U arg) function, U arg) async {
|
||||
final isolate = await IsolateRunner.spawn();
|
||||
try {
|
||||
return await isolate.run(function, arg);
|
||||
} finally {
|
||||
await isolate.close();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue