Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]:有没有个比较稳定的版本,总是卡死 #2169

Open
puyangdev opened this issue Jan 5, 2025 · 1 comment
Open

[Bug]:有没有个比较稳定的版本,总是卡死 #2169

puyangdev opened this issue Jan 5, 2025 · 1 comment
Labels
invalid This doesn't seem right

Comments

@puyangdev
Copy link

请描述遇到的问题,以及您所期望的正确的结果

func pushFlutterRoute(_ options: FlutterBoostRouteOptions!) {
    guard let navigationController = topViewController()?.navigationController,let engine = FlutterEngineManager.shared.engine else { return  }
    let pageName:String = options?.pageName ?? ""
    let uniqueId:String = options?.uniqueId ?? pageName
    let arguments: [String: Any] = options?.arguments as? [String: Any] ?? [:]
    let opaque:Bool = options?.uniqueId as? Bool ?? false

    let vc:FBFlutterViewContainer = FBFlutterViewContainer()
    vc.setName(pageName, uniqueId: uniqueId, params: arguments, opaque: opaque)
    // 是否伴随动画
    var animated = true
    if let animatedValue = options.arguments["animated"] as? NSNumber {
        animated = animatedValue.boolValue
    }
    // 是否是以 present 的方式打开
    let present = (options.arguments["present"] as? Bool ?? false) || !options.opaque
    if present {
        navigationController.present(vc, animated: animated) {
            options.completion?(true)
        }
    } else {
        navigationController.pushViewController(vc, animated: animated)
        options.completion?(true)
    }
}

请说明如何操作会遇到上述问题

func pushFlutterRoute(_ options: FlutterBoostRouteOptions!) {
    guard let navigationController = topViewController()?.navigationController,let engine = FlutterEngineManager.shared.engine else { return  }
    let pageName:String = options?.pageName ?? ""
    let uniqueId:String = options?.uniqueId ?? pageName
    let arguments: [String: Any] = options?.arguments as? [String: Any] ?? [:]
    let opaque:Bool = options?.uniqueId as? Bool ?? false

    let vc:FBFlutterViewContainer = FBFlutterViewContainer()
    vc.setName(pageName, uniqueId: uniqueId, params: arguments, opaque: opaque)
    // 是否伴随动画
    var animated = true
    if let animatedValue = options.arguments["animated"] as? NSNumber {
        animated = animatedValue.boolValue
    }
    // 是否是以 present 的方式打开
    let present = (options.arguments["present"] as? Bool ?? false) || !options.opaque
    if present {
        navigationController.present(vc, animated: animated) {
            options.completion?(true)
        }
    } else {
        navigationController.pushViewController(vc, animated: animated)
        options.completion?(true)
    }
}

在下面填入关键复现代码

func pushFlutterRoute(_ options: FlutterBoostRouteOptions!) {
    guard let navigationController = topViewController()?.navigationController,let engine = FlutterEngineManager.shared.engine else { return  }
    let pageName:String = options?.pageName ?? ""
    let uniqueId:String = options?.uniqueId ?? pageName
    let arguments: [String: Any] = options?.arguments as? [String: Any] ?? [:]
    let opaque:Bool = options?.uniqueId as? Bool ?? false

    let vc:FBFlutterViewContainer = FBFlutterViewContainer()
    vc.setName(pageName, uniqueId: uniqueId, params: arguments, opaque: opaque)
    // 是否伴随动画
    var animated = true
    if let animatedValue = options.arguments["animated"] as? NSNumber {
        animated = animatedValue.boolValue
    }
    // 是否是以 present 的方式打开
    let present = (options.arguments["present"] as? Bool ?? false) || !options.opaque
    if present {
        navigationController.present(vc, animated: animated) {
            options.completion?(true)
        }
    } else {
        navigationController.pushViewController(vc, animated: animated)
        options.completion?(true)
    }
}

复现的平台

iOS

Flutter SDK版本

3.27.1

FlutterBoost版本

4.6.5

是否延迟初始化FlutterBoost

No

解决方案

@puyangdev
Copy link
Author

let options = FlutterBoostRouteOptions()
options.pageName = "homePage"
options.uniqueId = "(Int.random(in: 1...10000000000))"
options.opaque = false
options.arguments = ["key" :"value"]

    //这个是push操作完成的回调,而不是页面关闭的回调!!!!
    options.completion = { completion in
        print("open operation is completed")
    }

    //这个是页面关闭并且返回数据的回调,回调实际需要根据您的Delegate中的popRoute来调用
    options.onPageFinished = { dic in
        print(dic)
    }

    FlutterBoost.instance().open(options)

@joechan-cq joechan-cq added the invalid This doesn't seem right label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants