Flutter与原生通信

文章目录

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);
        });
    原文作者:woscsw
    原文地址: https://blog.csdn.net/u010505059/article/details/86593957
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞