Flutter与原生通信

文章目录

  • IOS-->Flutter

IOS–>Flutter

xxx.m中

NSObject* _messenger;//自己找到messenger在哪

FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel messageChannelWithName:@"back_page" binaryMessenger:_messenger];
[channel sendMessage:@"back"];

xxx.dart中

static const BasicMessageChannel messageChannel= const BasicMessageChannel("back_page", StandardMessageCodec());

messageChannel.setMessageHandler((dynamic value) {
//接收到信息
            Navigator.pop(context);
        });

你可能感兴趣的:(flutter)