TestDefaultBinaryMessenger class Null safety
A BinaryMessenger subclass that is used as the default binary messenger under testing environment.
It tracks status of data sent across the Flutter platform barrier, which is useful for testing frameworks to monitor and synchronize against the platform messages.
Messages from the framework to the platform
Messages are sent from the framework to the platform via the send method.
To intercept a message sent from the framework to the platform, consider using setMockMessageHandler, setMockDecodedMessageHandler, and setMockMethodCallHandler (see also checkMockMessageHandler).
To wait for all pending framework-to-platform messages, the platformMessagesFinished getter provides an appropriate Future. The pendingMessageCount getter returns the current number of outstanding messages.
Messages from the platform to the framework
The platform sends messages via the ChannelBuffers API. Mock messages can be sent to the framework using handlePlatformMessage.
Listeners for these messages are configured using setMessageHandler.
- Inheritance
-
- Object
- BinaryMessenger
- TestDefaultBinaryMessenger
- Available Extensions
Constructors
- TestDefaultBinaryMessenger(BinaryMessenger delegate)
- Creates a TestDefaultBinaryMessenger instance.
Properties
- allMessagesHandler ↔ AllMessagesHandler?
-
Handler that intercepts and responds to outgoing messages, pretending
to be the platform, for all channels.
read / write
- delegate → BinaryMessenger
-
The delegate BinaryMessenger.
final
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- pendingMessageCount → int
-
The number of incomplete/pending calls sent to the platform channels.
read-only
-
platformMessagesFinished
→ Future<
void> -
Returns a Future that completes after all the platform calls are finished.
read-only
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
Methods
-
checkMockMessageHandler(
String channel, Object? handler) → bool -
Returns true if the
handler
argument matches thehandler
previously passed to setMockMessageHandler, setMockDecodedMessageHandler, or setMockMethodCallHandler. -
handlePlatformMessage(
String channel, ByteData? data, PlatformMessageResponseCallback? callback) → Future< ByteData?> -
Send a mock message to the framework as if it came from the platform.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
send(
String channel, ByteData? message) → Future< ByteData?> ? -
Send a binary message to the platform plugins on the given channel.
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
-
setMockDecodedMessageHandler<
T> (BasicMessageChannel< T> channel, Future<T> handler(T? message)?) → void - Set a callback for intercepting messages sent to the platform on the given channel.
-
setMockMessageHandler(
String channel, MessageHandler? handler, [Object? identity]) → void - Set a callback for intercepting messages sent to the platform on the given channel, without decoding them.
-
setMockMethodCallHandler(
MethodChannel channel, Future< Object?> ? handler(MethodCall message)?) → void - Set a callback for intercepting method calls sent to the platform on the given channel.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited