use void callback for setBackgroundImage to correctly free pointer after dispatch

This commit is contained in:
Nick Fisher
2024-04-20 13:46:10 +08:00
parent 49229f8c88
commit 15882891e2
4 changed files with 12 additions and 6 deletions

View File

@@ -531,8 +531,10 @@ class FilamentControllerFFI extends FilamentController {
throw Exception("No viewer available, ignoring");
}
final pathPtr = path.toNativeUtf8().cast<Char>();
await _withVoidCallback((cb) {
set_background_image_ffi(_viewer!, pathPtr, fillHeight, cb);
});
set_background_image_ffi(_viewer!, pathPtr, fillHeight);
allocator.free(pathPtr);
}

View File

@@ -1147,13 +1147,14 @@ external void clear_background_image_ffi(
);
@ffi.Native<
ffi.Void Function(
ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, ffi.Bool)>(
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
ffi.Bool, ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(
symbol: 'set_background_image_ffi', assetId: 'flutter_filament_plugin')
external void set_background_image_ffi(
ffi.Pointer<ffi.Void> viewer,
ffi.Pointer<ffi.Char> path,
bool fillHeight,
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
);
@ffi.Native<