tizen_interop_callbacks

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

tizen interop callbacks

tizen_interop_callbacks #

A Flutter plugin to resolve issues related to the error message: Cannot invoke native callback outside an isolate.
This package is designed to be used with the tizen_interop package.
Similarly to tizen_interop, this package has no build time dependency on a specific Tizen profile or version.
Usage #


Add this package and tizen_interop as dependencies in your pubspec.yaml file.
dependencies:
ffi: ^2.0.1
tizen_interop: ^0.3.0
tizen_interop_callbacks: ^0.2.0
copied to clipboard


In your Dart code, import the packages:
import 'dart:ffi';
import 'package:tizen_interop/5.5/tizen.dart';
import 'package:tizen_interop_callbacks/tizen_interop_callbacks.dart';
copied to clipboard


Instantiate the TizenInteropCallbacks class. This should be done in the root isolate - the thread where your main() is called.
final callbacks = TizenInteropCallbacks();
copied to clipboard


Implement your callback in Dart and register it with TizenInteropCallbacks:
final callback = _callbacks.register<Void Function(Int32, Pointer<Void>, Pointer<Void>)>(
'device_changed_cb',
Pointer.fromFunction(_batteryChanged),
);
copied to clipboard
The native function type to be used in register<>() can be obtained by checking
the definition of the related callback type - the device_changed_cb in this case.


Pass the obtained callback pointer and user_data to the Native API function:

Warning
Both interopCallback and interopUserData must be passed. The callback handling implementation relies on the interopUserData.
The only exceptions are a few callbacks that do not accept user_data parameters.

final ret = tizen.device_add_callback(
device_callback_e.DEVICE_CALLBACK_BATTERY_CAPACITY,
callback.interopCallback,
callback.interopUserData,
);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.