如何将初始值传递给ios Flutter插件类?

时间:2020-07-22 13:24:37

标签: ios swift flutter dart plugins

我正在迅速为Flutter开发一个ios插件。我在将初始值传递给插件类时遇到麻烦。

这是swift插件类:

public class SwiftTorusDirectPlugin: NSObject, FlutterPlugin {

  let torusSwiftDirectSDK: TorusSwiftDirectSDK;

  
  override public init(){

   let subVerifierDetails =  SubVerifierDetails(loginType: .installed,
                                                    loginProvider: .google,
                                                    clientId: "",
                                                    verifierName: "",
                                                    redirectURL: "")

    self.torusSwiftDirectSDK = TorusSwiftDirectSDK(aggregateVerifierType: .singleLogin, 
                                                            aggregateVerifierName: "", 
                                                            subVerifierDetails: [subVerifierDetails], loglevel: .trace)
    super.init()                                              
  }



  public static func register(with registrar: FlutterPluginRegistrar) {
    let channel = FlutterMethodChannel(name: "torus.flutter.dev/torus-direct", binaryMessenger: registrar.messenger())
    let instance = SwiftTorusDirectPlugin()
    registrar.addMethodCallDelegate(instance, channel: channel)
  }

  public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
    switch call.method {
        case "triggerLogin":
            self.torusSwiftDirectSDK.triggerLogin(browserType: .external).done
            { 
              data in print("private key rebuild", data)
              result(data)
            }   
        default:
            result(FlutterMethodNotImplemented)
        }
    } 
  }

是否可以通过Flutter将参数传递给插件的init方法(clientId,verifierName等)?

0 个答案:

没有答案