Provide default method call handler for SystemChannels.textInput (#101087)
This commit is contained in:
parent
d647755ee3
commit
78885ecbeb
@ -17,6 +17,7 @@ import 'message_codec.dart';
|
|||||||
import 'raw_keyboard.dart';
|
import 'raw_keyboard.dart';
|
||||||
import 'restoration.dart';
|
import 'restoration.dart';
|
||||||
import 'system_channels.dart';
|
import 'system_channels.dart';
|
||||||
|
import 'text_input.dart';
|
||||||
|
|
||||||
/// Listens for platform messages and directs them to the [defaultBinaryMessenger].
|
/// 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.system.setMessageHandler((dynamic message) => handleSystemMessage(message as Object));
|
||||||
SystemChannels.lifecycle.setMessageHandler(_handleLifecycleMessage);
|
SystemChannels.lifecycle.setMessageHandler(_handleLifecycleMessage);
|
||||||
SystemChannels.platform.setMethodCallHandler(_handlePlatformMessage);
|
SystemChannels.platform.setMethodCallHandler(_handlePlatformMessage);
|
||||||
|
TextInput.ensureInitialized();
|
||||||
readInitialLifecycleStateFromNativeWindow();
|
readInitialLifecycleStateFromNativeWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1575,6 +1575,12 @@ class TextInput {
|
|||||||
TextInputAction.emergencyCall,
|
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.
|
/// Begin interacting with the text input control.
|
||||||
///
|
///
|
||||||
/// Calling this function helps multiple clients coordinate about which one is
|
/// Calling this function helps multiple clients coordinate about which one is
|
||||||
|
@ -107,4 +107,11 @@ void main() {
|
|||||||
await rootBundle.loadString('test_asset2');
|
await rootBundle.loadString('test_asset2');
|
||||||
expect(flutterAssetsCallCount, 4);
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user