Moved the default BinaryMessenger instance to ServicesBinding (#37489)

This commit is contained in:
adazh
2019-08-09 10:13:40 -07:00
committed by GitHub
parent 20ecae0e92
commit 92ef2b9ce1
30 changed files with 243 additions and 161 deletions

View File

@@ -11,6 +11,6 @@ void main() {
Ticker((Duration duration) { })..start();
final ByteData message = const StringCodec().encodeMessage('AppLifecycleState.paused');
await defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', message, (_) {});
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', message, (_) {});
});
}

View File

@@ -36,9 +36,9 @@ Future<String> respondToHostRequestForSplashLog(String _) {
void createTestChannelBetweenAndroidAndFlutter() {
// Channel used for Android to send Flutter changes to the splash display.
final BasicMessageChannel<String> testChannel = BasicMessageChannel<String>(
const BasicMessageChannel<String> testChannel = BasicMessageChannel<String>(
'testChannel',
const StringCodec()
StringCodec()
);
// Every splash display change message that we receive from Android is either

View File

@@ -25,6 +25,8 @@ const BasicMessageChannel<String> _kReloadChannel =
BasicMessageChannel<String>(_kReloadChannelName, StringCodec());
void main() {
// Ensures bindings are initialized before doing anything.
WidgetsFlutterBinding.ensureInitialized();
// Start listening immediately for messages from the iOS side. ObjC calls
// will be made to let us know when we should be changing the app state.
_kReloadChannel.setMessageHandler(run);