Flutter与原生通信
程序员文章站
2022-05-25 19:51:09
...
文章目录
IOS–>Flutter
xxx.m中
NSObject<FlutterBinaryMessenger>* _messenger;//自己找到messenger在哪
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel messageChannelWithName:@"back_page" binaryMessenger:_messenger];
[channel sendMessage:@"back"];
xxx.dart中
static const BasicMessageChannel<dynamic> messageChannel= const BasicMessageChannel("back_page", StandardMessageCodec());
messageChannel.setMessageHandler((dynamic value) {
//接收到信息
Navigator.pop(context);
});