Feedback on function - partial apply of closure

I'm dealing with an error.

- Line 0
partial apply for thunk for at escaping at callee_unowned at convention(block) (at unowned Swift.AnyObject?) -> ()

partial apply for closure #2 in AppDelegate.tagItem(result:call:) + 214

Here's the code:

func tagItem(result: at escaping FlutterResult, call: FlutterMethodCall) {
        if let args = call.arguments as? Dictionary<String, Any>,
        let itemId = args["itemId"] as? String,
        let itemType = args["itemType"] as? Int,
        itemType >= 0 && itemType < 10 {
            let vdrItemType = VDRJourneyType.init(rawValue: UInt(itemType))
            VDRDataManager.tagItem(itemId, withTag: vdrItemType!, success: {
                result(true)
            }) { (error: Error?) in
                result(FlutterError(code: error?.localizedDescription ?? "An error came up tagging item", message: "An error came up tagging item", details: error))
            }
        } else {
            result(FlutterError(code: "bad_args", message: "Missing or invalid argument", details: nil))
        }
    }

Any ideas / feedback?

This function (tagItem) is called from within AppDelegate (FlutterAppDelegate) from func application(application:, didFinishLaunchingWithOptions...

In there I set up a FlutterMethodChannel which takes in the call and forwards it like so:

    let methodChannel = FlutterMethodChannel(name: "...",
                                              binaryMessenger: controller.binaryMessenger)
    methodChannel.setMethodCallHandler({
      [weak self] (call: FlutterMethodCall, result: at escaping FlutterResult) -> Void in
        if call.method == "tagItem" {
            self?.tagItem(result: result, call: call)
        }
Terms of Service

Privacy Policy

Cookie Policy