Unverified Commit 78885ecb authored by Jami Couch's avatar Jami Couch Committed by GitHub

Provide default method call handler for SystemChannels.textInput (#101087)

parent d647755e
......@@ -17,6 +17,7 @@ import 'message_codec.dart';
import 'raw_keyboard.dart';
import 'restoration.dart';
import 'system_channels.dart';
import 'text_input.dart';
/// Listens for platform messages and directs them to the [defaultBinaryMessenger].
///
......@@ -36,6 +37,7 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
SystemChannels.system.setMessageHandler((dynamic message) => handleSystemMessage(message as Object));
SystemChannels.lifecycle.setMessageHandler(_handleLifecycleMessage);
SystemChannels.platform.setMethodCallHandler(_handlePlatformMessage);
TextInput.ensureInitialized();
readInitialLifecycleStateFromNativeWindow();
}
......
......@@ -1575,6 +1575,12 @@ class TextInput {
TextInputAction.emergencyCall,
];
/// Ensure that a [TextInput] instance has been set up so that the platform
/// can handle messages on the text input method channel.
static void ensureInitialized() {
_instance; // ignore: unnecessary_statements
}
/// Begin interacting with the text input control.
///
/// Calling this function helps multiple clients coordinate about which one is
......
......@@ -107,4 +107,11 @@ void main() {
await rootBundle.loadString('test_asset2');
expect(flutterAssetsCallCount, 4);
});
test('initInstances sets a default method call handler for SystemChannels.textInput', () async {
final ByteData message = const JSONMessageCodec().encodeMessage(<String, dynamic>{'method': 'TextInput.requestElementsInRect', 'args': null})!;
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/textinput', message, (ByteData? data) {
expect(data, isNotNull);
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment