@@ -2,17 +2,59 @@ import "package:duit_kernel/duit_kernel.dart";
22import "package:duit_kernel/src/capabilities/driver_ref.dart" ;
33import "package:meta/meta.dart" ;
44
5+ /// A mixin that provides capabilities for managing and interacting with
6+ /// native code in the Duit UI system. Classes that mix in this delegate should
7+ /// provide concrete implementations for handling native module interactions,
8+ /// such as invoking native methods and initializing the native module.
59mixin NativeModuleCapabilityDelegate implements DriverRefHolder {
610 @override
711 @mustBeOverridden
8- void linkDriver (UIDriver driver) => throw const MissingCapabilityMethodImplementation (
12+ void linkDriver (UIDriver driver) =>
13+ throw const MissingCapabilityMethodImplementation (
914 "linkDriver" ,
1015 "NativeModuleCapabilityDelegate" ,
1116 );
1217
18+ /// Initializes the native module.
19+ ///
20+ /// This method must be overridden by implementers.
21+ ///
22+ /// Throws [MissingCapabilityMethodImplementation] if not overridden.
1323 @mustBeOverridden
14- Future <void > initNativeModule () => throw const MissingCapabilityMethodImplementation (
24+ Future <void > initNativeModule () =>
25+ throw const MissingCapabilityMethodImplementation (
1526 "initNativeModule" ,
1627 "NativeModuleCapabilityDelegate" ,
1728 );
29+
30+ /// Invokes a native method.
31+ ///
32+ /// The [method] parameter represents the name of the native method to invoke.
33+ /// The [arguments] parameter contains any additional data required for the method.
34+ ///
35+ /// This method must be overridden by implementers.
36+ ///
37+ /// Throws [MissingCapabilityMethodImplementation] if not overridden.
38+ @mustBeOverridden
39+ Future <T ?> invokeNativeMethod <T >(
40+ String method, [
41+ arguments,
42+ ]) =>
43+ throw const MissingCapabilityMethodImplementation (
44+ "invokeNativeMethod" ,
45+ "NativeModuleCapabilityDelegate" ,
46+ );
47+
48+ /// Called to clean up any external resources, subscriptions, or handlers
49+ /// typically when a delegate is being disposed of or detached. Implementations
50+ /// should ensure all open streams or event sources are closed.
51+ ///
52+ /// This method must be overridden by implementers.
53+ ///
54+ /// Throws [MissingCapabilityMethodImplementation] by default.
55+ @mustBeOverridden
56+ void releaseResources () => throw const MissingCapabilityMethodImplementation (
57+ "releaseResources" ,
58+ "NativeModuleCapabilityDelegate" ,
59+ );
1860}
0 commit comments