Revert "Moved the default BinaryMessenger instance to ServicesBinding (#37489)" (#37983)

This reverts commit 92ef2b9ce1.

This requires either runApp() or
WidgetsFlutterBinding.ensureInitialized() to have been called before
using any MethodChannels. Plugins broadly rely on MethodChannels and
right now there's no general requirements that they be constructed
within the runApp call, so the ecosystem breakages from this are broader
than originally thought. Reverting for now.
This commit is contained in:
Michael Klimushyn
2019-08-09 16:30:30 -07:00
committed by GitHub
parent 77e15103da
commit 821602aef3
30 changed files with 161 additions and 243 deletions

View File

@@ -11,6 +11,6 @@ void main() {
Ticker((Duration duration) { })..start();
final ByteData message = const StringCodec().encodeMessage('AppLifecycleState.paused');
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', message, (_) {});
await 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.
const BasicMessageChannel<String> testChannel = BasicMessageChannel<String>(
final BasicMessageChannel<String> testChannel = BasicMessageChannel<String>(
'testChannel',
StringCodec()
const StringCodec()
);
// Every splash display change message that we receive from Android is either

View File

@@ -25,8 +25,6 @@ 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);