当前位置 : 主页 > 手机开发 > ROM >

flutter实现promise中resolve功能

来源:互联网 收集:自由互联 发布时间:2021-06-10
BehaviorSubject openCameraController = BehaviorSubject(); BridgeChannel _openCamera() { print( ‘- - - - - - - - - - - - - - - - - - _openCamera() ‘ ); return BridgeChannel( name: ‘openCamera‘ , onBridgeHandler: (dataFromJs) async {

 

BehaviorSubject openCameraController = BehaviorSubject();
    BridgeChannel _openCamera() {
        print(‘- - - - - - - - - - - - - - - - - - > _openCamera() ‘);
        return BridgeChannel(
            name: ‘openCamera‘,
            onBridgeHandler: (dataFromJs) async {
                print(‘- - - - - - - - - - - - - - - - - - > _openCamera() 发送事件 ‘+dataFromJs);
                EventBus().post(OpenCameraEvent(dataFromJs));
                print(‘- - - - - - - - - - - - - - - - - -222 > openCameraController.listen2  ‘);
                return await doSome();
            }
        );
    }

    Future<String> doSome() async {
        var a = new Future(() => null);
        openCameraController.listen((resul) {
            print(‘- - - - - - - - - - - - - - - - - - > openCameraController.listen ‘+resul);
            //return result = resul;
            //call(‘dart2Js‘, resul);
            a.then((_) => resul);
        });
        return a;
    }
网友评论