// Autogenerated from Pigeon (v26.1.5), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation #if os(iOS) import Flutter #elseif os(macOS) import FlutterMacOS #else #error("Unsupported platform.") #endif /// Error class for passing custom error details to Dart side. final class PigeonError: Error { let code: String let message: String? let details: Sendable? init(code: String, message: String?, details: Sendable?) { self.code = code self.message = message self.details = details } var localizedDescription: String { return "PigeonError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" } } private func wrapResult(_ result: Any?) -> [Any?] { return [result] } private func wrapError(_ error: Any) -> [Any?] { if let pigeonError = error as? PigeonError { return [ pigeonError.code, pigeonError.message, pigeonError.details, ] } if let flutterError = error as? FlutterError { return [ flutterError.code, flutterError.message, flutterError.details, ] } return [ "\(error)", "\(type(of: error))", "Stacktrace: \(Thread.callStackSymbols)", ] } private func isNullish(_ value: Any?) -> Bool { return value is NSNull || value == nil } private func nilOrValue(_ value: Any?) -> T? { if value is NSNull { return nil } return value as! T? } private class MessagesPigeonCodecReader: FlutterStandardReader { } private class MessagesPigeonCodecWriter: FlutterStandardWriter { } private class MessagesPigeonCodecReaderWriter: FlutterStandardReaderWriter { override func reader(with data: Data) -> FlutterStandardReader { return MessagesPigeonCodecReader(data: data) } override func writer(with data: NSMutableData) -> FlutterStandardWriter { return MessagesPigeonCodecWriter(data: data) } } class MessagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { static let shared = MessagesPigeonCodec(readerWriter: MessagesPigeonCodecReaderWriter()) } /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol VibrateApi { func canVibrate() throws -> Bool func vibrate(duration: Int64) throws func impact() throws func selection() throws func success() throws func warning() throws func error() throws func heavy() throws func medium() throws func light() throws } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class VibrateApiSetup { static var codec: FlutterStandardMessageCodec { MessagesPigeonCodec.shared } /// Sets up an instance of `VibrateApi` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: VibrateApi?, messageChannelSuffix: String = "") { let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" let canVibrateChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.canVibrate\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { canVibrateChannel.setMessageHandler { _, reply in do { let result = try api.canVibrate() reply(wrapResult(result)) } catch { reply(wrapError(error)) } } } else { canVibrateChannel.setMessageHandler(nil) } let vibrateChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.vibrate\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { vibrateChannel.setMessageHandler { message, reply in let args = message as! [Any?] let durationArg = args[0] as! Int64 do { try api.vibrate(duration: durationArg) reply(wrapResult(nil)) } catch { reply(wrapError(error)) } } } else { vibrateChannel.setMessageHandler(nil) } let impactChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.impact\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { impactChannel.setMessageHandler { _, reply in do { try api.impact() reply(wrapResult(nil)) } catch { reply(wrapError(error)) } } } else { impactChannel.setMessageHandler(nil) } let selectionChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.selection\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { selectionChannel.setMessageHandler { _, reply in do { try api.selection() reply(wrapResult(nil)) } catch { reply(wrapError(error)) } } } else { selectionChannel.setMessageHandler(nil) } let successChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.success\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { successChannel.setMessageHandler { _, reply in do { try api.success() reply(wrapResult(nil)) } catch { reply(wrapError(error)) } } } else { successChannel.setMessageHandler(nil) } let warningChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.warning\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { warningChannel.setMessageHandler { _, reply in do { try api.warning() reply(wrapResult(nil)) } catch { reply(wrapError(error)) } } } else { warningChannel.setMessageHandler(nil) } let errorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.error\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { errorChannel.setMessageHandler { _, reply in do { try api.error() reply(wrapResult(nil)) } catch { reply(wrapError(error)) } } } else { errorChannel.setMessageHandler(nil) } let heavyChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.heavy\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { heavyChannel.setMessageHandler { _, reply in do { try api.heavy() reply(wrapResult(nil)) } catch { reply(wrapError(error)) } } } else { heavyChannel.setMessageHandler(nil) } let mediumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.medium\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { mediumChannel.setMessageHandler { _, reply in do { try api.medium() reply(wrapResult(nil)) } catch { reply(wrapError(error)) } } } else { mediumChannel.setMessageHandler(nil) } let lightChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.flutter_vibrate.VibrateApi.light\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { lightChannel.setMessageHandler { _, reply in do { try api.light() reply(wrapResult(nil)) } catch { reply(wrapError(error)) } } } else { lightChannel.setMessageHandler(nil) } } }