欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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);
        });
相关标签: flutter