美文网首页
Flutter - flutter_boost集成踩坑(修改源码

Flutter - flutter_boost集成踩坑(修改源码

作者: 神灬渐入嘉靜 | 来源:发表于2020-08-03 16:53 被阅读0次

    flutter_boost分支:v1.17.1-hotfixes

    Android

    • 修复:跳转到flutter的webview页面后返回崩溃和webview中无法进行编辑的情况

    XTextInputPlugin.java文件 222行

            if (inputTarget.type == InputTarget.Type.PLATFORM_VIEW) {
                if (isInputConnectionLocked) {
                    return lastInputConnection;
                }
                lastInputConnection = platformViewsController.getPlatformViewById(inputTarget.id).onCreateInputConnection(outAttrs);
                return lastInputConnection;
            }
    

    修改为以下代码:

            if (inputTarget.type == InputTarget.Type.PLATFORM_VIEW) {
                if (isInputConnectionLocked) {
                    return lastInputConnection;
                }
                if (platformViewsController != null && platformViewsController.getPlatformViewById(inputTarget.id) != null) {
                    lastInputConnection = platformViewsController.getPlatformViewById(inputTarget.id).onCreateInputConnection(outAttrs);
                } else {
                    return lastInputConnection;
                }
                return lastInputConnection;
            }
    
    • 修复:从flutter的webview页面跳转到页面返回后webview无法滑动、交互的问题

    FlutterActivityAndFragmentDelegate.java文件 237行

            if(ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE!=0||
                    ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE==this.host.getActivity().hashCode()){
                flutterEngine.getActivityControlSurface().detachFromActivityForConfigChanges();
            }
    

    注释掉

    //        if(ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE!=0||
    //                ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE==this.host.getActivity().hashCode()){
    //            flutterEngine.getActivityControlSurface().detachFromActivityForConfigChanges();
    //        }
    

    iOS

    • 修复:flutter作为tabbar的根视图互相切换时会有明显的闪屏

    FLBFlutterViewContainer.m文件 285行

    if([UIApplication sharedApplication].applicationState == UIApplicationStateActive){
            //NOTES:务必在show之后再update,否则有闪烁; 或导致侧滑返回时上一个页面会和top页面内容一样
            [self surfaceUpdated:YES];
    }
    

    修改为:

        if([UIApplication sharedApplication].applicationState == UIApplicationStateActive){
            //NOTES:务必在show之后再update,否则有闪烁; 或导致侧滑返回时上一个页面会和top页面内容一样
    //        [self surfaceUpdated:YES];
            
            /// 延迟刷新 避免闪屏
            __block FlutterViewController *weakSelf = self;
            dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.1 * NSEC_PER_SEC));
            dispatch_after(delayTime, dispatch_get_main_queue(), ^{
                [weakSelf surfaceUpdated:YES];
            });
        }
    

    目前所有修改不确保稳定、仅为解决刚性问题临时方案

    相关文章

      网友评论

          本文标题:Flutter - flutter_boost集成踩坑(修改源码

          本文链接:https://www.haomeiwen.com/subject/wyhbrktx.html