BloomNativeModule class abstract

Base class for all native Bloom modules bridging Dart to host iOS/Android platforms.

Encapsulates platform channel dispatching, synchronous state cache, long-running hardware event streams, typed exception translation, and lifecycle notifications.

Example:

class BloomDeviceModule extends BloomNativeModule {
  BloomDeviceModule() : super(name: 'BloomDevice');

  Future<String> getDeviceModel() async {
    final result = await invokeAsync<String>('getDeviceModel');
    return result ?? 'Unknown';
  }
}

Constructors

BloomNativeModule({required String name, String version = '1.0.0', MethodChannel? customMethodChannel, EventChannel? customEventChannel})
Creates a BloomNativeModule instance.

Properties

constants Map<String, dynamic>
Cached static constants provided by the native platform.
no setter
eventChannel EventChannel?
Underlying event channel for streaming continuous events from the host platform.
no setter
hashCode int
The hash code for this object.
no setterinherited
isInitialized bool
Whether the module is initialized and ready for platform calls.
no setter
methodChannel MethodChannel?
Underlying method channel for dispatching calls to the host platform.
no setter
name String
The unique module name identifier (e.g. 'BloomCamera', 'BloomLocation').
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
version String
Semantic version of the native module contract (defaults to '1.0.0').
final

Methods

emitEvent(String streamName, dynamic payload) → void
Emits an event from native callback or test mock into the stream.
getProperty<T>(String key) → T?
Synchronously returns a locally cached property or constant.
invokeAsync<T>(String method, [Map<String, dynamic>? args, NativeThread thread = NativeThread.ui]) Future<T?>
Invokes an asynchronous native method across the platform boundary.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDispose() Future<void>
Invoked when the module is unregistered from the registry or explicitly disposed.
onHostPause() → void
Invoked when the host application transitions to background.
onHostResume() → void
Invoked when the host application resumes from background into foreground.
onInit() Future<void>
Invoked when the module is registered into BloomModuleRegistry.
setConstant(String key, dynamic value) → void
Sets a local constant or cached property in this module.
subscribeStream<T>(String streamName, [Map<String, dynamic>? args]) Stream<T>
Subscribes to a long-running native hardware stream or event channel.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited