@@ -34,7 +34,9 @@ private func wrapError(_ error: Any) -> [Any?] {
34
34
}
35
35
36
36
private func createConnectionError( withChannelName channelName: String ) -> FlutterError {
37
- return FlutterError ( code: " channel-error " , message: " Unable to establish connection on channel: ' \( channelName) '. " , details: " " )
37
+ return FlutterError (
38
+ code: " channel-error " , message: " Unable to establish connection on channel: ' \( channelName) '. " ,
39
+ details: " " )
38
40
}
39
41
40
42
private func isNullish( _ value: Any ? ) -> Bool {
@@ -130,7 +132,9 @@ class ExampleHostApiSetup {
130
132
static var codec : FlutterStandardMessageCodec { ExampleHostApiCodec . shared }
131
133
/// Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`.
132
134
static func setUp( binaryMessenger: FlutterBinaryMessenger , api: ExampleHostApi ? ) {
133
- let getHostLanguageChannel = FlutterBasicMessageChannel ( name: " dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage " , binaryMessenger: binaryMessenger, codec: codec)
135
+ let getHostLanguageChannel = FlutterBasicMessageChannel (
136
+ name: " dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage " ,
137
+ binaryMessenger: binaryMessenger, codec: codec)
134
138
if let api = api {
135
139
getHostLanguageChannel. setMessageHandler { _, reply in
136
140
do {
@@ -143,7 +147,9 @@ class ExampleHostApiSetup {
143
147
} else {
144
148
getHostLanguageChannel. setMessageHandler ( nil )
145
149
}
146
- let addChannel = FlutterBasicMessageChannel ( name: " dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add " , binaryMessenger: binaryMessenger, codec: codec)
150
+ let addChannel = FlutterBasicMessageChannel (
151
+ name: " dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add " ,
152
+ binaryMessenger: binaryMessenger, codec: codec)
147
153
if let api = api {
148
154
addChannel. setMessageHandler { message, reply in
149
155
let args = message as! [ Any ? ]
@@ -159,7 +165,9 @@ class ExampleHostApiSetup {
159
165
} else {
160
166
addChannel. setMessageHandler ( nil )
161
167
}
162
- let sendMessageChannel = FlutterBasicMessageChannel ( name: " dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage " , binaryMessenger: binaryMessenger, codec: codec)
168
+ let sendMessageChannel = FlutterBasicMessageChannel (
169
+ name: " dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage " ,
170
+ binaryMessenger: binaryMessenger, codec: codec)
163
171
if let api = api {
164
172
sendMessageChannel. setMessageHandler { message, reply in
165
173
let args = message as! [ Any ? ]
@@ -180,15 +188,19 @@ class ExampleHostApiSetup {
180
188
}
181
189
/// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift.
182
190
protocol MessageFlutterApiProtocol {
183
- func flutterMethod( aString aStringArg: String ? , completion: @escaping ( Result < String , FlutterError > ) -> Void )
191
+ func flutterMethod(
192
+ aString aStringArg: String ? , completion: @escaping ( Result < String , FlutterError > ) -> Void )
184
193
}
185
194
class MessageFlutterApi : MessageFlutterApiProtocol {
186
195
private let binaryMessenger : FlutterBinaryMessenger
187
196
init ( binaryMessenger: FlutterBinaryMessenger ) {
188
197
self . binaryMessenger = binaryMessenger
189
198
}
190
- func flutterMethod( aString aStringArg: String ? , completion: @escaping ( Result < String , FlutterError > ) -> Void ) {
191
- let channelName : String = " dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod "
199
+ func flutterMethod(
200
+ aString aStringArg: String ? , completion: @escaping ( Result < String , FlutterError > ) -> Void
201
+ ) {
202
+ let channelName : String =
203
+ " dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod "
192
204
let channel = FlutterBasicMessageChannel ( name: channelName, binaryMessenger: binaryMessenger)
193
205
channel. sendMessage ( [ aStringArg] as [ Any ? ] ) { response in
194
206
guard let listResponse = response as? [ Any ? ] else {
@@ -201,7 +213,11 @@ class MessageFlutterApi: MessageFlutterApiProtocol {
201
213
let details : String ? = nilOrValue ( listResponse [ 2 ] )
202
214
completion ( . failure( FlutterError ( code: code, message: message, details: details) ) )
203
215
} else if listResponse [ 0 ] == nil {
204
- completion ( . failure( FlutterError ( code: " null-error " , message: " Flutter api returned null value for non-null return value. " , details: " " ) ) )
216
+ completion (
217
+ . failure(
218
+ FlutterError (
219
+ code: " null-error " ,
220
+ message: " Flutter api returned null value for non-null return value. " , details: " " ) ) )
205
221
} else {
206
222
let result = listResponse [ 0 ] as! String
207
223
completion ( . success( result) )
0 commit comments