Registrar class
A registrar for Flutter plugins implemented in Dart.
Plugins for the web platform are implemented in Dart and are
registered with this class by code generated by the flutter
tool
when compiling the application.
This class implements BinaryMessenger to route messages from the framework to registered plugins.
Use this BinaryMessenger when creating platform channels in order for them to receive messages from the platform side. For example:
class MyPlugin {
static void registerWith(Registrar registrar) {
final MethodChannel channel = MethodChannel(
'com.my_plugin/my_plugin',
const StandardMethodCodec(),
registrar, // the registrar is used as the BinaryMessenger
);
final MyPlugin instance = MyPlugin();
channel.setMethodCallHandler(instance.handleMethodCall);
}
Future<dynamic> handleMethodCall(MethodCall call) async {
// ...
}
// ...
}
- Inheritance
-
- Object
- BinaryMessenger
- Registrar
- Implementers
- Available Extensions
Constructors
- Registrar([@Deprecated('This argument is ignored. ' 'This feature was deprecated after v1.24.0-7.0.pre.') BinaryMessenger? binaryMessenger])
- Creates a Registrar.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- messenger → BinaryMessenger
-
Returns
this
.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
handleFrameworkMessage(
String channel, ByteData? data, PlatformMessageResponseCallback? callback) → Future< void> - Message handler for web plugins.
-
handlePlatformMessage(
String channel, ByteData? data, PlatformMessageResponseCallback? callback) → Future< void> -
Receives a platform message from the framework.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerMessageHandler(
) → void - Registers the registrar's message handler (handlePlatformMessage) with the engine, so that plugin messages are correctly dispatched to the relevant registered plugin.
-
send(
String channel, ByteData? message) → Future< ByteData?> -
Sends a platform message from the platform side back to the framework.
override
-
setMessageHandler(
String channel, MessageHandler? handler) → void -
Set a callback for receiving messages from the platform plugins on the
given channel, without decoding them.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited