diff --git a/packages/animations/example/ios/Runner/AppDelegate.swift b/packages/animations/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/animations/example/ios/Runner/AppDelegate.swift +++ b/packages/animations/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/dynamic_layouts/example/ios/Runner/AppDelegate.swift b/packages/dynamic_layouts/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/dynamic_layouts/example/ios/Runner/AppDelegate.swift +++ b/packages/dynamic_layouts/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/file_selector/file_selector/example/ios/Runner/AppDelegate.swift b/packages/file_selector/file_selector/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/file_selector/file_selector/example/ios/Runner/AppDelegate.swift +++ b/packages/file_selector/file_selector/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/file_selector/file_selector_ios/example/ios/Runner/AppDelegate.swift b/packages/file_selector/file_selector_ios/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/file_selector/file_selector_ios/example/ios/Runner/AppDelegate.swift +++ b/packages/file_selector/file_selector_ios/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/flutter_adaptive_scaffold/example/ios/Runner/AppDelegate.swift b/packages/flutter_adaptive_scaffold/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/flutter_adaptive_scaffold/example/ios/Runner/AppDelegate.swift +++ b/packages/flutter_adaptive_scaffold/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/flutter_image/example/ios/Runner/AppDelegate.swift b/packages/flutter_image/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/flutter_image/example/ios/Runner/AppDelegate.swift +++ b/packages/flutter_image/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/flutter_markdown/example/ios/Runner/AppDelegate.swift b/packages/flutter_markdown/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/flutter_markdown/example/ios/Runner/AppDelegate.swift +++ b/packages/flutter_markdown/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/go_router/example/ios/Runner/AppDelegate.swift b/packages/go_router/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/go_router/example/ios/Runner/AppDelegate.swift +++ b/packages/go_router/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/palette_generator/example/ios/Runner/AppDelegate.swift b/packages/palette_generator/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/palette_generator/example/ios/Runner/AppDelegate.swift +++ b/packages/palette_generator/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift b/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift index 5530b8be026d..16f2edb84c9c 100644 --- a/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift +++ b/packages/path_provider/path_provider_foundation/darwin/Classes/PathProviderPlugin.swift @@ -5,62 +5,63 @@ import Foundation #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #endif public class PathProviderPlugin: NSObject, FlutterPlugin, PathProviderApi { public static func register(with registrar: FlutterPluginRegistrar) { let instance = PathProviderPlugin() // Workaround for https://github.com/flutter/flutter/issues/118103. -#if os(iOS) - let messenger = registrar.messenger() -#else - let messenger = registrar.messenger -#endif + #if os(iOS) + let messenger = registrar.messenger() + #else + let messenger = registrar.messenger + #endif PathProviderApiSetup.setUp(binaryMessenger: messenger, api: instance) } func getDirectoryPath(type: DirectoryType) -> String? { var path = getDirectory(ofType: fileManagerDirectoryForType(type)) - #if os(macOS) - // In a non-sandboxed app, these are shared directories where applications are - // expected to use its bundle ID as a subdirectory. (For non-sandboxed apps, - // adding the extra path is harmless). - // This is not done for iOS, for compatibility with older versions of the - // plugin. - if type == .applicationSupport || type == .applicationCache { - if let basePath = path { - let basePathURL = URL.init(fileURLWithPath: basePath) - path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path + #if os(macOS) + // In a non-sandboxed app, these are shared directories where applications are + // expected to use its bundle ID as a subdirectory. (For non-sandboxed apps, + // adding the extra path is harmless). + // This is not done for iOS, for compatibility with older versions of the + // plugin. + if type == .applicationSupport || type == .applicationCache { + if let basePath = path { + let basePathURL = URL.init(fileURLWithPath: basePath) + path = basePathURL.appendingPathComponent(Bundle.main.bundleIdentifier!).path + } } - } - #endif + #endif return path } // Returns the path for the container of the specified app group. func getContainerPath(appGroupIdentifier: String) -> String? { - return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)?.path + return FileManager.default.containerURL( + forSecurityApplicationGroupIdentifier: appGroupIdentifier)?.path } } /// Returns the FileManager constant corresponding to the given type. private func fileManagerDirectoryForType(_ type: DirectoryType) -> FileManager.SearchPathDirectory { switch type { - case .applicationCache: - return FileManager.SearchPathDirectory.cachesDirectory - case .applicationDocuments: - return FileManager.SearchPathDirectory.documentDirectory - case .applicationSupport: - return FileManager.SearchPathDirectory.applicationSupportDirectory - case .downloads: - return FileManager.SearchPathDirectory.downloadsDirectory - case .library: - return FileManager.SearchPathDirectory.libraryDirectory - case .temp: - return FileManager.SearchPathDirectory.cachesDirectory + case .applicationCache: + return FileManager.SearchPathDirectory.cachesDirectory + case .applicationDocuments: + return FileManager.SearchPathDirectory.documentDirectory + case .applicationSupport: + return FileManager.SearchPathDirectory.applicationSupportDirectory + case .downloads: + return FileManager.SearchPathDirectory.downloadsDirectory + case .library: + return FileManager.SearchPathDirectory.libraryDirectory + case .temp: + return FileManager.SearchPathDirectory.cachesDirectory } } diff --git a/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift b/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift index 99a56f2bfebf..67ee981673a9 100644 --- a/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift +++ b/packages/path_provider/path_provider_foundation/darwin/RunnerTests/RunnerTests.swift @@ -3,12 +3,13 @@ // found in the LICENSE file. import XCTest + @testable import path_provider_foundation #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #endif class RunnerTests: XCTestCase { @@ -39,28 +40,28 @@ class RunnerTests: XCTestCase { func testGetApplicationSupportDirectory() throws { let plugin = PathProviderPlugin() let path = plugin.getDirectoryPath(type: .applicationSupport) -#if os(iOS) - // On iOS, the application support directory path should be just the system application - // support path. - XCTAssertEqual( - path, - NSSearchPathForDirectoriesInDomains( - FileManager.SearchPathDirectory.applicationSupportDirectory, - FileManager.SearchPathDomainMask.userDomainMask, - true - ).first) -#else - // On macOS, the application support directory path should be the system application - // support path with an added subdirectory based on the app name. - XCTAssert( - path!.hasPrefix( + #if os(iOS) + // On iOS, the application support directory path should be just the system application + // support path. + XCTAssertEqual( + path, NSSearchPathForDirectoriesInDomains( FileManager.SearchPathDirectory.applicationSupportDirectory, FileManager.SearchPathDomainMask.userDomainMask, true - ).first!)) - XCTAssert(path!.hasSuffix("Example")) -#endif + ).first) + #else + // On macOS, the application support directory path should be the system application + // support path with an added subdirectory based on the app name. + XCTAssert( + path!.hasPrefix( + NSSearchPathForDirectoriesInDomains( + FileManager.SearchPathDirectory.applicationSupportDirectory, + FileManager.SearchPathDomainMask.userDomainMask, + true + ).first!)) + XCTAssert(path!.hasSuffix("Example")) + #endif } func testGetLibraryDirectory() throws { diff --git a/packages/path_provider/path_provider_foundation/example/ios/Runner/AppDelegate.swift b/packages/path_provider/path_provider_foundation/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/path_provider/path_provider_foundation/example/ios/Runner/AppDelegate.swift +++ b/packages/path_provider/path_provider_foundation/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/pigeon/example/app/ios/Runner/AppDelegate.swift b/packages/pigeon/example/app/ios/Runner/AppDelegate.swift index 3c7913122701..f259b7590852 100644 --- a/packages/pigeon/example/app/ios/Runner/AppDelegate.swift +++ b/packages/pigeon/example/app/ios/Runner/AppDelegate.swift @@ -15,14 +15,14 @@ private class PigeonApiImplementation: ExampleHostApi { } func add(_ a: Int64, to b: Int64) throws -> Int64 { - if (a < 0 || b < 0) { - throw FlutterError(code: "code", message: "message", details: "details"); + if a < 0 || b < 0 { + throw FlutterError(code: "code", message: "message", details: "details") } return a + b } func sendMessage(message: MessageData, completion: @escaping (Result) -> Void) { - if (message.code == Code.one) { + if message.code == Code.one { completion(.failure(FlutterError(code: "code", message: "message", details: "details"))) return } @@ -39,7 +39,9 @@ private class PigeonFlutterApi { flutterAPI = MessageFlutterApi(binaryMessenger: binaryMessenger) } - func callFlutterMethod(aString aStringArg: String?, completion: @escaping (Result) -> Void) { + func callFlutterMethod( + aString aStringArg: String?, completion: @escaping (Result) -> Void + ) { flutterAPI.flutterMethod(aString: aStringArg) { completion(.success($0)) } diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/RunnerTests/RunnerTests.swift b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/RunnerTests/RunnerTests.swift index e332af122ac4..46e5239c5700 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/RunnerTests/RunnerTests.swift +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/macos/RunnerTests/RunnerTests.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import FlutterMacOS import Cocoa +import FlutterMacOS import XCTest @testable import alternate_language_test_plugin diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/Runner/AppDelegate.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/Runner/AppDelegate.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift index ed6b53459469..7e7266940f5a 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift @@ -4,6 +4,7 @@ import Flutter import XCTest + @testable import test_plugin class AllDatatypesTests: XCTestCase { @@ -17,25 +18,25 @@ class AllDatatypesTests: XCTestCase { api.echoNullable(everything) { result in switch result { - case .success(let res) : - XCTAssertNotNil(res) - XCTAssertNil(res!.aNullableBool) - XCTAssertNil(res!.aNullableInt) - XCTAssertNil(res!.aNullableDouble) - XCTAssertNil(res!.aNullableString) - XCTAssertNil(res!.aNullableByteArray) - XCTAssertNil(res!.aNullable4ByteArray) - XCTAssertNil(res!.aNullable8ByteArray) - XCTAssertNil(res!.aNullableFloatArray) - XCTAssertNil(res!.aNullableList) - XCTAssertNil(res!.aNullableMap) - XCTAssertNil(res!.nullableNestedList) - XCTAssertNil(res!.nullableMapWithAnnotations) - XCTAssertNil(res!.nullableMapWithObject) - expectation.fulfill() - case .failure(_) : - return - + case .success(let res): + XCTAssertNotNil(res) + XCTAssertNil(res!.aNullableBool) + XCTAssertNil(res!.aNullableInt) + XCTAssertNil(res!.aNullableDouble) + XCTAssertNil(res!.aNullableString) + XCTAssertNil(res!.aNullableByteArray) + XCTAssertNil(res!.aNullable4ByteArray) + XCTAssertNil(res!.aNullable8ByteArray) + XCTAssertNil(res!.aNullableFloatArray) + XCTAssertNil(res!.aNullableList) + XCTAssertNil(res!.aNullableMap) + XCTAssertNil(res!.nullableNestedList) + XCTAssertNil(res!.nullableMapWithAnnotations) + XCTAssertNil(res!.nullableMapWithObject) + expectation.fulfill() + case .failure(_): + return + } } @@ -55,36 +56,36 @@ class AllDatatypesTests: XCTestCase { aNullableMap: ["hello": 1234], nullableNestedList: [[true, false], [true]], nullableMapWithAnnotations: ["hello": "world"], - nullableMapWithObject: ["hello": 1234, "goodbye" : "world"], + nullableMapWithObject: ["hello": 1234, "goodbye": "world"], aNullableString: "123" ) - + let binaryMessenger = EchoBinaryMessenger(codec: FlutterIntegrationCoreApiCodec.shared) let api = FlutterIntegrationCoreApi(binaryMessenger: binaryMessenger) let expectation = XCTestExpectation(description: "callback") api.echoNullable(everything) { result in - switch result { - case .success(let res) : - XCTAssertNotNil(res) - XCTAssertEqual(res!.aNullableBool, everything.aNullableBool) - XCTAssertEqual(res!.aNullableInt, everything.aNullableInt) - XCTAssertEqual(res!.aNullableDouble, everything.aNullableDouble) - XCTAssertEqual(res!.aNullableString, everything.aNullableString) - XCTAssertEqual(res!.aNullableByteArray, everything.aNullableByteArray) - XCTAssertEqual(res!.aNullable4ByteArray, everything.aNullable4ByteArray) - XCTAssertEqual(res!.aNullable8ByteArray, everything.aNullable8ByteArray) - XCTAssertEqual(res!.aNullableFloatArray, everything.aNullableFloatArray) - XCTAssert(equalsList(res!.aNullableList, everything.aNullableList)) - XCTAssert(equalsDictionary(res!.aNullableMap, everything.aNullableMap)) - XCTAssertEqual(res!.nullableNestedList, everything.nullableNestedList) - XCTAssertEqual(res!.nullableMapWithAnnotations, everything.nullableMapWithAnnotations) - XCTAssert(equalsDictionary(res!.nullableMapWithObject, everything.nullableMapWithObject)) - expectation.fulfill() - return - case .failure(_) : - return + switch result { + case .success(let res): + XCTAssertNotNil(res) + XCTAssertEqual(res!.aNullableBool, everything.aNullableBool) + XCTAssertEqual(res!.aNullableInt, everything.aNullableInt) + XCTAssertEqual(res!.aNullableDouble, everything.aNullableDouble) + XCTAssertEqual(res!.aNullableString, everything.aNullableString) + XCTAssertEqual(res!.aNullableByteArray, everything.aNullableByteArray) + XCTAssertEqual(res!.aNullable4ByteArray, everything.aNullable4ByteArray) + XCTAssertEqual(res!.aNullable8ByteArray, everything.aNullable8ByteArray) + XCTAssertEqual(res!.aNullableFloatArray, everything.aNullableFloatArray) + XCTAssert(equalsList(res!.aNullableList, everything.aNullableList)) + XCTAssert(equalsDictionary(res!.aNullableMap, everything.aNullableMap)) + XCTAssertEqual(res!.nullableNestedList, everything.nullableNestedList) + XCTAssertEqual(res!.nullableMapWithAnnotations, everything.nullableMapWithAnnotations) + XCTAssert(equalsDictionary(res!.nullableMapWithObject, everything.nullableMapWithObject)) + expectation.fulfill() + return + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AsyncHandlersTest.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AsyncHandlersTest.swift index f5852c47a980..f7e8db596063 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AsyncHandlersTest.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AsyncHandlersTest.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import Flutter import XCTest + @testable import test_plugin class MockHostSmallApi: HostSmallApi { @@ -27,12 +28,12 @@ class AsyncHandlersTest: XCTestCase { let expectation = XCTestExpectation(description: "callback") flutterApi.echo(value) { result in - switch result { - case .success(let res) : - XCTAssertEqual(res, value) - expectation.fulfill() - case .failure(_) : - return + switch result { + case .success(let res): + XCTAssertEqual(res, value) + expectation.fulfill() + case .failure(_): + return } } @@ -40,7 +41,8 @@ class AsyncHandlersTest: XCTestCase { } func testAsyncFlutter2HostVoidVoid() throws { - let binaryMessenger = MockBinaryMessenger(codec: FlutterStandardMessageCodec.sharedInstance()) + let binaryMessenger = MockBinaryMessenger( + codec: FlutterStandardMessageCodec.sharedInstance()) let mockHostSmallApi = MockHostSmallApi() HostSmallApiSetup.setUp(binaryMessenger: binaryMessenger, api: mockHostSmallApi) let channelName = "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.voidVoid" @@ -49,14 +51,15 @@ class AsyncHandlersTest: XCTestCase { let expectation = XCTestExpectation(description: "voidvoid callback") binaryMessenger.handlers[channelName]?(nil) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] - XCTAssertEqual(outputList?.first as! NSNull, NSNull()) + XCTAssertEqual(outputList?.first as! NSNull, NSNull()) expectation.fulfill() } wait(for: [expectation], timeout: 1.0) } func testAsyncFlutter2Host() throws { - let binaryMessenger = MockBinaryMessenger(codec: FlutterStandardMessageCodec.sharedInstance()) + let binaryMessenger = MockBinaryMessenger( + codec: FlutterStandardMessageCodec.sharedInstance()) let mockHostSmallApi = MockHostSmallApi() let value = "Test" mockHostSmallApi.output = value @@ -69,7 +72,7 @@ class AsyncHandlersTest: XCTestCase { let expectation = XCTestExpectation(description: "echo callback") binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] - let output = outputList?.first as? String + let output = outputList?.first as? String XCTAssertEqual(output, value) expectation.fulfill() } diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EchoBinaryMessenger.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EchoBinaryMessenger.swift index a2f524c2bd92..26c4de6eac79 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EchoBinaryMessenger.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EchoBinaryMessenger.swift @@ -2,30 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import Foundation import Flutter +import Foundation class EchoBinaryMessenger: NSObject, FlutterBinaryMessenger { let codec: FlutterMessageCodec private(set) var count = 0 var defaultReturn: Any? - + init(codec: FlutterMessageCodec) { self.codec = codec super.init() } - + func send(onChannel channel: String, message: Data?) { // Method not implemented because this messenger is just for echoing } - + func send( onChannel channel: String, message: Data?, binaryReply callback: FlutterBinaryReply? = nil ) { guard let callback = callback else { return } - + guard let args = self.codec.decode(message) as? [Any?], let firstArg = args.first, @@ -34,20 +34,21 @@ class EchoBinaryMessenger: NSObject, FlutterBinaryMessenger { callback(self.defaultReturn.flatMap { self.codec.encode([$0]) }) return } - + callback(self.codec.encode([castedFirstArg])) } - + func setMessageHandlerOnChannel( - _ channel: String, binaryMessageHandler handler: - FlutterBinaryMessageHandler? = nil + _ channel: String, + binaryMessageHandler handler: + FlutterBinaryMessageHandler? = nil ) -> FlutterBinaryMessengerConnection { self.count += 1 return FlutterBinaryMessengerConnection(self.count) } - + func cleanUpConnection(_ connection: FlutterBinaryMessengerConnection) { - // Method not implemented because this messenger is just for echoing + // Method not implemented because this messenger is just for echoing } private func nilOrValue(_ value: Any?) -> T? { diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EnumTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EnumTests.swift index 2c8c0cc41199..391ace5d9148 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EnumTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/EnumTests.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin class MockEnumApi2Host: EnumApi2Host { @@ -32,7 +33,7 @@ class EnumTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputMap = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputMap) - + let output = outputMap?.first as? DataWithEnum XCTAssertEqual(output, input) XCTAssertTrue(outputMap?.count == 1) @@ -49,11 +50,11 @@ class EnumTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.echo(data: data) { result in switch result { - case .success(let res) : - XCTAssertEqual(res.state, res.state) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(res.state, res.state) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/HandlerBinaryMessenger.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/HandlerBinaryMessenger.swift index fda20a40da54..7bd4394f9e0b 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/HandlerBinaryMessenger.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/HandlerBinaryMessenger.swift @@ -2,42 +2,42 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import Foundation import Flutter +import Foundation -typealias HandlerBinaryMessengerHandler = ([Any?])-> Any +typealias HandlerBinaryMessengerHandler = ([Any?]) -> Any class HandlerBinaryMessenger: NSObject, FlutterBinaryMessenger { let codec: FlutterMessageCodec let handler: HandlerBinaryMessengerHandler private var count = 0 - + init(codec: FlutterMessageCodec, handler: @escaping HandlerBinaryMessengerHandler) { self.codec = codec self.handler = handler super.init() } - + func send(onChannel channel: String, message: Data?) { // Method not implemented because this messenger is just for handling } - + func send( onChannel channel: String, message: Data?, binaryReply callback: FlutterBinaryReply? = nil ) { guard let callback = callback else { return } - + guard let args = self.codec.decode(message) as? [Any?] else { callback(nil) return } - + let result = self.handler(args) callback(self.codec.encode([result])) } - + func setMessageHandlerOnChannel( _ channel: String, binaryMessageHandler handler: FlutterBinaryMessageHandler? = nil @@ -45,7 +45,7 @@ class HandlerBinaryMessenger: NSObject, FlutterBinaryMessenger { self.count += 1 return FlutterBinaryMessengerConnection(self.count) } - + func cleanUpConnection(_ connection: FlutterBinaryMessengerConnection) { // Method not implemented because this messenger is just for handling } diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/ListTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/ListTests.swift index b096ed2bc587..4fc7de6b96e3 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/ListTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/ListTests.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin class ListTests: XCTestCase { @@ -16,13 +17,13 @@ class ListTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.echo(top) { result in switch result { - case .success(let res) : - XCTAssertEqual(1, res.testList?.count) - XCTAssertTrue(res.testList?[0] is TestMessage) - XCTAssert(equalsList(inside.testList, (res.testList?[0] as! TestMessage).testList)) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(1, res.testList?.count) + XCTAssertTrue(res.testList?[0] is TestMessage) + XCTAssert(equalsList(inside.testList, (res.testList?[0] as! TestMessage).testList)) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MockBinaryMessenger.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MockBinaryMessenger.swift index 9f7f9483b1ea..23aa9d5b5773 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MockBinaryMessenger.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MockBinaryMessenger.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import Flutter + @testable import test_plugin class MockBinaryMessenger: NSObject, FlutterBinaryMessenger { diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MultipleArityTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MultipleArityTests.swift index 52155f8927a4..f42933b2391a 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MultipleArityTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/MultipleArityTests.swift @@ -4,6 +4,7 @@ import Flutter import XCTest + @testable import test_plugin class MockMultipleArityHostApi: MultipleArityHostApi { @@ -16,7 +17,8 @@ class MultipleArityTests: XCTestCase { var codec = FlutterStandardMessageCodec.sharedInstance() func testSimpleHost() throws { let binaryMessenger = MockBinaryMessenger(codec: EnumApi2HostCodec.shared) - MultipleArityHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: MockMultipleArityHostApi()) + MultipleArityHostApiSetup.setUp( + binaryMessenger: binaryMessenger, api: MockMultipleArityHostApi()) let channelName = "dev.flutter.pigeon.pigeon_integration_tests.MultipleArityHostApi.subtract" XCTAssertNotNil(binaryMessenger.handlers[channelName]) @@ -28,10 +30,10 @@ class MultipleArityTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList![0] as? Int64 XCTAssertEqual(3, output) - XCTAssertTrue(outputList?.count == 1) + XCTAssertTrue(outputList?.count == 1) expectation.fulfill() } wait(for: [expectation], timeout: 1.0) @@ -46,11 +48,11 @@ class MultipleArityTests: XCTestCase { let expectation = XCTestExpectation(description: "subtraction") api.subtract(x: 30, y: 10) { result in switch result { - case .success(let res) : - XCTAssertEqual(20, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(20, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NSNullFieldTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NSNullFieldTests.swift index 036608f2fd8a..a10a88d01fae 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NSNullFieldTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NSNullFieldTests.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin /// Tests NSNull is correctly handled by `nilOrValue` helper, by manually setting nullable fields to NSNull. diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NonNullFieldsTest.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NonNullFieldsTest.swift index ce1f4579a88d..07ccb6b6c6f7 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NonNullFieldsTest.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NonNullFieldsTest.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin class NonNullFieldsTests: XCTestCase { diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NullableReturnsTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NullableReturnsTests.swift index dca9d6e3d6ee..cf56bebd58a9 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NullableReturnsTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/NullableReturnsTests.swift @@ -4,6 +4,7 @@ import Flutter import XCTest + @testable import test_plugin class MockNullableArgHostApi: NullableArgHostApi { @@ -27,11 +28,11 @@ class NullableReturnsTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.doit(x: nil) { result in switch result { - case .success(let res) : - XCTAssertEqual(99, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(99, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift index 86b118e7f620..2f99f45f1e91 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/PrimitiveTests.swift @@ -4,12 +4,13 @@ import Flutter import XCTest + @testable import test_plugin class MockPrimitiveHostApi: PrimitiveHostApi { func anInt(value: Int64) -> Int64 { value } func aBool(value: Bool) -> Bool { value } - func aString(value: String) -> String { value } + func aString(value: String) -> String { value } func aDouble(value: Double) -> Double { value } func aMap(value: [AnyHashable: Any?]) -> [AnyHashable: Any?] { value } func aList(value: [Any?]) -> [Any?] { value } @@ -34,7 +35,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? Int64 XCTAssertEqual(1, output) XCTAssertTrue(outputList!.count == 1) @@ -50,12 +51,12 @@ class PrimitiveTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.anInt(value: 1) { result in switch result { - case .success(let res) : - XCTAssertEqual(1, res) - expectation.fulfill() - case .failure(_) : - return - + case .success(let res): + XCTAssertEqual(1, res) + expectation.fulfill() + case .failure(_): + return + } } wait(for: [expectation], timeout: 1.0) @@ -74,7 +75,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? Bool XCTAssertEqual(true, output) XCTAssertTrue(outputList!.count == 1) @@ -90,11 +91,11 @@ class PrimitiveTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") api.aBool(value: true) { result in switch result { - case .success(let res) : - XCTAssertEqual(true, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(true, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) @@ -113,7 +114,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? Double XCTAssertEqual(1.0, output) XCTAssertTrue(outputList!.count == 1) @@ -130,11 +131,11 @@ class PrimitiveTests: XCTestCase { let arg: Double = 1.5 api.aDouble(value: arg) { result in switch result { - case .success(let res) : - XCTAssertEqual(arg, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(arg, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) @@ -153,7 +154,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? String XCTAssertEqual("hello", output) XCTAssertTrue(outputList!.count == 1) @@ -170,11 +171,11 @@ class PrimitiveTests: XCTestCase { let arg: String = "hello" api.aString(value: arg) { result in switch result { - case .success(let res) : - XCTAssertEqual(arg, res) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssertEqual(arg, res) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) @@ -193,7 +194,7 @@ class PrimitiveTests: XCTestCase { binaryMessenger.handlers[channelName]?(inputEncoded) { data in let outputList = binaryMessenger.codec.decode(data) as? [Any] XCTAssertNotNil(outputList) - + let output = outputList!.first as? [Int] XCTAssertEqual([1, 2, 3], output) XCTAssertTrue(outputList!.count == 1) @@ -210,11 +211,11 @@ class PrimitiveTests: XCTestCase { let arg = ["hello"] api.aList(value: arg) { result in switch result { - case .success(let res) : - XCTAssert(equalsList(arg, res)) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssert(equalsList(arg, res)) + expectation.fulfill() + case .failure(_): + return } } wait(for: [expectation], timeout: 1.0) @@ -250,11 +251,11 @@ class PrimitiveTests: XCTestCase { let arg = ["hello": 1] api.aMap(value: arg) { result in switch result { - case .success(let res) : - XCTAssert(equalsDictionary(arg, res)) - expectation.fulfill() - case .failure(_) : - return + case .success(let res): + XCTAssert(equalsDictionary(arg, res)) + expectation.fulfill() + case .failure(_): + return } } diff --git a/packages/pigeon/platform_tests/test_plugin/example/macos/RunnerTests/BasicCompileTest.swift b/packages/pigeon/platform_tests/test_plugin/example/macos/RunnerTests/BasicCompileTest.swift index a828ca540e80..b3a751166b03 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/macos/RunnerTests/BasicCompileTest.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/macos/RunnerTests/BasicCompileTest.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import XCTest + @testable import test_plugin class MyApi: HostTrivialApi { diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift index 8b4daf5a08ed..0d04c9544ca1 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift @@ -7,10 +7,8 @@ import UIKit extension FlutterError: Error {} -/** - * This plugin handles the native side of the integration tests in - * example/integration_test/. - */ +/// This plugin handles the native side of the integration tests in +/// example/integration_test/. public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { var flutterAPI: FlutterIntegrationCoreApi @@ -90,15 +88,18 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func extractNestedNullableString(from wrapper: AllClassesWrapper) -> String? { - return wrapper.allNullableTypes.aNullableString; + return wrapper.allNullableTypes.aNullableString } func createNestedObject(with nullableString: String?) -> AllClassesWrapper { return AllClassesWrapper(allNullableTypes: AllNullableTypes(aNullableString: nullableString)) } - func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?) -> AllNullableTypes { - let someThings = AllNullableTypes(aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) + func sendMultipleNullableTypes( + aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String? + ) -> AllNullableTypes { + let someThings = AllNullableTypes( + aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) return someThings } @@ -178,7 +179,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(everything)) } - func echoAsync(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) { + func echoAsync( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { completion(.success(everything)) } @@ -198,7 +202,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aString)) } - func echoAsync(_ aUint8List: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { + func echoAsync( + _ aUint8List: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { completion(.success(aUint8List)) } @@ -210,7 +217,9 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aList)) } - func echoAsync(_ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) { + func echoAsync( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void + ) { completion(.success(aMap)) } @@ -222,7 +231,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(anInt)) } - func echoAsyncNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) + { completion(.success(aDouble)) } @@ -230,11 +240,15 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aBool)) } - func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) + { completion(.success(aString)) } - func echoAsyncNullable(_ aUint8List: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable( + _ aUint8List: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { completion(.success(aUint8List)) } @@ -246,66 +260,74 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aList)) } - func echoAsyncNullable(_ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) { + func echoAsyncNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void + ) { completion(.success(aMap)) } - func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) + { completion(.success(anEnum)) } func callFlutterNoop(completion: @escaping (Result) -> Void) { - flutterAPI.noop() { response in + flutterAPI.noop { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } func callFlutterThrowError(completion: @escaping (Result) -> Void) { - flutterAPI.throwError() { response in + flutterAPI.throwError { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } func callFlutterThrowErrorFromVoid(completion: @escaping (Result) -> Void) { - flutterAPI.throwErrorFromVoid() { response in + flutterAPI.throwErrorFromVoid { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ everything: AllTypes, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ everything: AllTypes, completion: @escaping (Result) -> Void + ) { flutterAPI.echo(everything) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) - } + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } } } - func callFlutterEcho(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(everything) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) - } + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } } } @@ -321,10 +343,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { aString: aNullableString ) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -332,10 +354,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aBool: Bool, completion: @escaping (Result) -> Void) { flutterAPI.echo(aBool) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -343,10 +365,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ anInt: Int64, completion: @escaping (Result) -> Void) { flutterAPI.echo(anInt) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -354,10 +376,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aDouble: Double, completion: @escaping (Result) -> Void) { flutterAPI.echo(aDouble) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -365,21 +387,24 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aString: String, completion: @escaping (Result) -> Void) { flutterAPI.echo(aString) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ aList: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { flutterAPI.echo(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -387,21 +412,23 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { flutterAPI.echo(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ aMap: [String? : Any?], completion: @escaping (Result<[String? : Any?], Error>) -> Void) { + func callFlutterEcho( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void + ) { flutterAPI.echo(aMap) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -409,99 +436,115 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) { flutterAPI.echo(anEnum) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) + { flutterAPI.echoNullable(aBool) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ anInt: Int64?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ anInt: Int64?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(anInt) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ aDouble: Double?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aDouble) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aString: String?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ aString: String?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aString) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - - func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { + + func callFlutterEchoNullable( + _ aList: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) { + func callFlutterEchoNullable( + _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void + ) { flutterAPI.echoNullable(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aMap: [String? : Any?]?, completion: @escaping (Result<[String? : Any?]?, Error>) -> Void) { + func callFlutterEchoNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void + ) { flutterAPI.echoNullable(aMap) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterNullableEcho(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) { + func callFlutterNullableEcho( + _ anEnum: AnEnum?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(anEnum) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } - } + } } } diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift index c82f94b1c0b1..5da16290c7a0 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift @@ -7,10 +7,8 @@ import FlutterMacOS extension FlutterError: Error {} -/** - * This plugin handles the native side of the integration tests in - * example/integration_test/. - */ +/// This plugin handles the native side of the integration tests in +/// example/integration_test/. public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { var flutterAPI: FlutterIntegrationCoreApi @@ -102,15 +100,18 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func extractNestedNullableString(from wrapper: AllClassesWrapper) -> String? { - return wrapper.allNullableTypes.aNullableString; + return wrapper.allNullableTypes.aNullableString } func createNestedObject(with nullableString: String?) -> AllClassesWrapper { return AllClassesWrapper(allNullableTypes: AllNullableTypes(aNullableString: nullableString)) } - func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?) -> AllNullableTypes { - let someThings = AllNullableTypes(aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) + func sendMultipleNullableTypes( + aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String? + ) -> AllNullableTypes { + let someThings = AllNullableTypes( + aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) return someThings } @@ -178,7 +179,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(everything)) } - func echoAsync(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) { + func echoAsync( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { completion(.success(everything)) } @@ -198,7 +202,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aString)) } - func echoAsync(_ aUint8List: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { + func echoAsync( + _ aUint8List: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { completion(.success(aUint8List)) } @@ -210,7 +217,9 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aList)) } - func echoAsync(_ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) { + func echoAsync( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void + ) { completion(.success(aMap)) } @@ -222,7 +231,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(anInt)) } - func echoAsyncNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) + { completion(.success(aDouble)) } @@ -230,11 +240,15 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aBool)) } - func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) + { completion(.success(aString)) } - func echoAsyncNullable(_ aUint8List: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable( + _ aUint8List: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { completion(.success(aUint8List)) } @@ -246,66 +260,74 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(aList)) } - func echoAsyncNullable(_ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) { + func echoAsyncNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void + ) { completion(.success(aMap)) } - func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) { + func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) + { completion(.success(anEnum)) } func callFlutterNoop(completion: @escaping (Result) -> Void) { - flutterAPI.noop() { response in + flutterAPI.noop { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } func callFlutterThrowError(completion: @escaping (Result) -> Void) { - flutterAPI.throwError() { response in + flutterAPI.throwError { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } func callFlutterThrowErrorFromVoid(completion: @escaping (Result) -> Void) { - flutterAPI.throwErrorFromVoid() { response in + flutterAPI.throwErrorFromVoid { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ everything: AllTypes, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ everything: AllTypes, completion: @escaping (Result) -> Void + ) { flutterAPI.echo(everything) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) - } + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } } } - func callFlutterEcho(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(everything) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) - } + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) + } } } @@ -321,10 +343,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { aString: aNullableString ) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -332,10 +354,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aBool: Bool, completion: @escaping (Result) -> Void) { flutterAPI.echo(aBool) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -343,10 +365,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ anInt: Int64, completion: @escaping (Result) -> Void) { flutterAPI.echo(anInt) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -354,10 +376,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aDouble: Double, completion: @escaping (Result) -> Void) { flutterAPI.echo(aDouble) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -365,21 +387,24 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aString: String, completion: @escaping (Result) -> Void) { flutterAPI.echo(aString) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { + func callFlutterEcho( + _ aList: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { flutterAPI.echo(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -387,21 +412,23 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { flutterAPI.echo(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEcho(_ aMap: [String? : Any?], completion: @escaping (Result<[String? : Any?], Error>) -> Void) { + func callFlutterEcho( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void + ) { flutterAPI.echo(aMap) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } @@ -409,99 +436,115 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func callFlutterEcho(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) { flutterAPI.echo(anEnum) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) + { flutterAPI.echoNullable(aBool) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ anInt: Int64?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ anInt: Int64?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(anInt) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ aDouble: Double?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aDouble) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aString: String?, completion: @escaping (Result) -> Void) { + func callFlutterEchoNullable( + _ aString: String?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aString) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - - func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { + + func callFlutterEchoNullable( + _ aList: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) { + func callFlutterEchoNullable( + _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void + ) { flutterAPI.echoNullable(aList) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterEchoNullable(_ aMap: [String? : Any?]?, completion: @escaping (Result<[String? : Any?]?, Error>) -> Void) { + func callFlutterEchoNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void + ) { flutterAPI.echoNullable(aMap) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } } } - func callFlutterNullableEcho(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) { + func callFlutterNullableEcho( + _ anEnum: AnEnum?, completion: @escaping (Result) -> Void + ) { flutterAPI.echoNullable(anEnum) { response in switch response { - case .success(let res): - completion(.success(res)) - case .failure(let error): - completion(.failure(error)) + case .success(let res): + completion(.success(res)) + case .failure(let error): + completion(.failure(error)) } - } + } } } diff --git a/packages/platform/example/ios/Runner/AppDelegate.swift b/packages/platform/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/platform/example/ios/Runner/AppDelegate.swift +++ b/packages/platform/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/pointer_interceptor/pointer_interceptor/example/ios/Runner/AppDelegate.swift b/packages/pointer_interceptor/pointer_interceptor/example/ios/Runner/AppDelegate.swift index 41be7b255972..8891e986b166 100644 --- a/packages/pointer_interceptor/pointer_interceptor/example/ios/Runner/AppDelegate.swift +++ b/packages/pointer_interceptor/pointer_interceptor/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { @@ -13,12 +13,12 @@ import Flutter ) -> Bool { GeneratedPluginRegistrant.register(with: self) - weak var registrar = self.registrar(forPlugin: "DummyPlatform"); + weak var registrar = self.registrar(forPlugin: "DummyPlatform") let factory = DummyPlatformViewFactory(messenger: registrar!.messenger()) self.registrar(forPlugin: "")!.register( - factory, - withId: "dummy_platform_view") + factory, + withId: "dummy_platform_view") return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/packages/pointer_interceptor/pointer_interceptor/example/ios/Runner/DummyPlatformViewFactory.swift b/packages/pointer_interceptor/pointer_interceptor/example/ios/Runner/DummyPlatformViewFactory.swift index 5ea634fa9226..45f468b3acfc 100644 --- a/packages/pointer_interceptor/pointer_interceptor/example/ios/Runner/DummyPlatformViewFactory.swift +++ b/packages/pointer_interceptor/pointer_interceptor/example/ios/Runner/DummyPlatformViewFactory.swift @@ -5,9 +5,7 @@ import Flutter import UIKit -/** - * A simple factory that creates a dummy platform view for testing. - */ +/// A simple factory that creates a dummy platform view for testing. public class DummyPlatformViewFactory: NSObject, FlutterPlatformViewFactory { private var messenger: FlutterBinaryMessenger @@ -33,38 +31,34 @@ public class DummyPlatformViewFactory: NSObject, FlutterPlatformViewFactory { } } -/** - * A native view that will remove it's tag if clicked. - */ +/// A native view that will remove it's tag if clicked. public class CustomView: UIView { - var timesClicked = 0; + var timesClicked = 0 var nativeLabel = UILabel() override public func hitTest( _ point: CGPoint, with event: UIEvent? ) -> UIView? { - if (viewWithTag(1) != nil) { - viewWithTag(1)?.removeFromSuperview(); - createNativeView(view: self); + if viewWithTag(1) != nil { + viewWithTag(1)?.removeFromSuperview() + createNativeView(view: self) } - timesClicked += 1; + timesClicked += 1 nativeLabel.text = "Traversed \(timesClicked) subviews" return super.hitTest(point, with: event) } - func createNativeView(view _view: CustomView){ + func createNativeView(view _view: CustomView) { nativeLabel.text = "Traversed \(timesClicked) subviews" nativeLabel.frame = CGRect(x: 0, y: 0, width: 180, height: 48.0) _view.addSubview(nativeLabel) } } -/** - * A flutter platform view that displays a simple native view. - */ +/// A flutter platform view that displays a simple native view. class DummyPlatformView: NSObject, FlutterPlatformView { - private var _view: CustomView; + private var _view: CustomView init( frame: CGRect, @@ -81,9 +75,9 @@ class DummyPlatformView: NSObject, FlutterPlatformView { return _view } - func createNativeView(view _view: CustomView){ + func createNativeView(view _view: CustomView) { let nativeLabel = UILabel() - nativeLabel.tag = 1; + nativeLabel.tag = 1 nativeLabel.text = "Native View Not Clicked" nativeLabel.frame = CGRect(x: 0, y: 0, width: 180, height: 48.0) _view.addSubview(nativeLabel) diff --git a/packages/pointer_interceptor/pointer_interceptor_ios/example/ios/Runner/AppDelegate.swift b/packages/pointer_interceptor/pointer_interceptor_ios/example/ios/Runner/AppDelegate.swift index 41be7b255972..8891e986b166 100644 --- a/packages/pointer_interceptor/pointer_interceptor_ios/example/ios/Runner/AppDelegate.swift +++ b/packages/pointer_interceptor/pointer_interceptor_ios/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { @@ -13,12 +13,12 @@ import Flutter ) -> Bool { GeneratedPluginRegistrant.register(with: self) - weak var registrar = self.registrar(forPlugin: "DummyPlatform"); + weak var registrar = self.registrar(forPlugin: "DummyPlatform") let factory = DummyPlatformViewFactory(messenger: registrar!.messenger()) self.registrar(forPlugin: "")!.register( - factory, - withId: "dummy_platform_view") + factory, + withId: "dummy_platform_view") return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/packages/pointer_interceptor/pointer_interceptor_ios/example/ios/Runner/DummyPlatformViewFactory.swift b/packages/pointer_interceptor/pointer_interceptor_ios/example/ios/Runner/DummyPlatformViewFactory.swift index 71b1bff63b14..5723fdac74f0 100644 --- a/packages/pointer_interceptor/pointer_interceptor_ios/example/ios/Runner/DummyPlatformViewFactory.swift +++ b/packages/pointer_interceptor/pointer_interceptor_ios/example/ios/Runner/DummyPlatformViewFactory.swift @@ -5,9 +5,7 @@ import Flutter import UIKit -/** - * A simple factory that creates a dummy platform view for testing. - */ +/// A simple factory that creates a dummy platform view for testing. public class DummyPlatformViewFactory: NSObject, FlutterPlatformViewFactory { private var messenger: FlutterBinaryMessenger @@ -33,25 +31,21 @@ public class DummyPlatformViewFactory: NSObject, FlutterPlatformViewFactory { } } -/** - * A native view that will remove its tag if clicked. - */ +/// A native view that will remove its tag if clicked. public class CustomView: UIView { override public func hitTest( _ point: CGPoint, with event: UIEvent? ) -> UIView? { - viewWithTag(1)?.removeFromSuperview(); + viewWithTag(1)?.removeFromSuperview() return super.hitTest(point, with: event) } } -/** - * A flutter platform view that displays a simple native view. - */ +/// A flutter platform view that displays a simple native view. class DummyPlatformView: NSObject, FlutterPlatformView { - private var _view: CustomView; + private var _view: CustomView init( frame: CGRect, @@ -68,10 +62,10 @@ class DummyPlatformView: NSObject, FlutterPlatformView { return _view } - func createNativeView(view _view: CustomView){ + func createNativeView(view _view: CustomView) { let nativeLabel = UILabel() _view.isUserInteractionEnabled = true - nativeLabel.tag = 1; + nativeLabel.tag = 1 nativeLabel.text = "Not Clicked" nativeLabel.frame = CGRect(x: 0, y: 0, width: 180, height: 48.0) _view.addSubview(nativeLabel) diff --git a/packages/quick_actions/quick_actions_ios/example/ios/RunnerUITests/RunnerUITests.swift b/packages/quick_actions/quick_actions_ios/example/ios/RunnerUITests/RunnerUITests.swift index 2ac4fdbc46a9..ad4c03f008ea 100644 --- a/packages/quick_actions/quick_actions_ios/example/ios/RunnerUITests/RunnerUITests.swift +++ b/packages/quick_actions/quick_actions_ios/example/ios/RunnerUITests/RunnerUITests.swift @@ -18,7 +18,7 @@ private let pressDurationRetryAdjustment: TimeInterval = 0.2 // This is to deflake a situation where the quick action menu is not present after // the long press. // See: https://github.com/flutter/flutter/issues/125509 -private let quickActionMaxRetries: Int = 4; +private let quickActionMaxRetries: Int = 4 class RunnerUITests: XCTestCase { @@ -40,7 +40,8 @@ class RunnerUITests: XCTestCase { let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") let quickActionsAppIcon = springboard.icons["quick_actions_example"] - findAndTapQuickActionButton(buttonName: "Action two", quickActionsAppIcon: quickActionsAppIcon, springboard: springboard); + findAndTapQuickActionButton( + buttonName: "Action two", quickActionsAppIcon: quickActionsAppIcon, springboard: springboard) let actionTwoConfirmation = exampleApp.otherElements["action_two"] if !actionTwoConfirmation.waitForExistence(timeout: elementWaitingTime) { @@ -73,7 +74,8 @@ class RunnerUITests: XCTestCase { ) } - findAndTapQuickActionButton(buttonName: "Action one", quickActionsAppIcon: quickActionsAppIcon, springboard: springboard); + findAndTapQuickActionButton( + buttonName: "Action one", quickActionsAppIcon: quickActionsAppIcon, springboard: springboard) let actionOneConfirmation = exampleApp.otherElements["action_one"] if !actionOneConfirmation.waitForExistence(timeout: elementWaitingTime) { @@ -85,7 +87,9 @@ class RunnerUITests: XCTestCase { XCTAssert(actionOneConfirmation.exists) } - private func findAndTapQuickActionButton(buttonName: String, quickActionsAppIcon: XCUIElement, springboard: XCUIElement) { + private func findAndTapQuickActionButton( + buttonName: String, quickActionsAppIcon: XCUIElement, springboard: XCUIElement + ) { var actionButton: XCUIElement? var pressDuration = quickActionPressDuration for _ in 1...quickActionMaxRetries { @@ -111,12 +115,12 @@ class RunnerUITests: XCTestCase { // Reset to previous state. XCUIDevice.shared.press(XCUIDevice.Button.home) } - if (!actionButton!.exists) { + if !actionButton!.exists { XCTFail( "Failed due to not able to find the \(buttonName) button from springboard with \(elementWaitingTime) seconds. Springboard debug description: \(springboard.debugDescription)" ) } - actionButton!.tap(); + actionButton!.tap() } } diff --git a/packages/rfw/example/hello/ios/Runner/AppDelegate.swift b/packages/rfw/example/hello/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/rfw/example/hello/ios/Runner/AppDelegate.swift +++ b/packages/rfw/example/hello/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/rfw/example/local/ios/Runner/AppDelegate.swift b/packages/rfw/example/local/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/rfw/example/local/ios/Runner/AppDelegate.swift +++ b/packages/rfw/example/local/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/rfw/example/remote/ios/Runner/AppDelegate.swift b/packages/rfw/example/remote/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/rfw/example/remote/ios/Runner/AppDelegate.swift +++ b/packages/rfw/example/remote/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/shared_preferences/shared_preferences/example/ios/Runner/AppDelegate.swift b/packages/shared_preferences/shared_preferences/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/shared_preferences/shared_preferences/example/ios/Runner/AppDelegate.swift +++ b/packages/shared_preferences/shared_preferences/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/shared_preferences/shared_preferences_foundation/darwin/Classes/SharedPreferencesPlugin.swift b/packages/shared_preferences/shared_preferences_foundation/darwin/Classes/SharedPreferencesPlugin.swift index fcfe97e568c0..b88562e8398d 100644 --- a/packages/shared_preferences/shared_preferences_foundation/darwin/Classes/SharedPreferencesPlugin.swift +++ b/packages/shared_preferences/shared_preferences_foundation/darwin/Classes/SharedPreferencesPlugin.swift @@ -5,24 +5,24 @@ import Foundation #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #endif public class SharedPreferencesPlugin: NSObject, FlutterPlugin, UserDefaultsApi { public static func register(with registrar: FlutterPluginRegistrar) { let instance = SharedPreferencesPlugin() // Workaround for https://github.com/flutter/flutter/issues/118103. -#if os(iOS) - let messenger = registrar.messenger() -#else - let messenger = registrar.messenger -#endif + #if os(iOS) + let messenger = registrar.messenger() + #else + let messenger = registrar.messenger + #endif UserDefaultsApiSetup.setUp(binaryMessenger: messenger, api: instance) } - func getAll(prefix: String, allowList: [String]?) -> [String? : Any?] { + func getAll(prefix: String, allowList: [String]?) -> [String?: Any?] { return getAllPrefs(prefix: prefix, allowList: allowList) } @@ -47,21 +47,22 @@ public class SharedPreferencesPlugin: NSObject, FlutterPlugin, UserDefaultsApi { for (key, _) in getAllPrefs(prefix: prefix, allowList: allowList) { defaults.removeObject(forKey: key) } - return true + return true } /// Returns all preferences stored with specified prefix. /// If [allowList] is included, only items included will be returned. func getAllPrefs(prefix: String, allowList: [String]?) -> [String: Any] { var filteredPrefs: [String: Any] = [:] - var allowSet: Set?; + var allowSet: Set? if let allowList = allowList { allowSet = Set(allowList) } if let appDomain = Bundle.main.bundleIdentifier, let prefs = UserDefaults.standard.persistentDomain(forName: appDomain) { - for (key, value) in prefs where (key.hasPrefix(prefix) && (allowSet == nil || allowSet!.contains(key))) { + for (key, value) in prefs + where (key.hasPrefix(prefix) && (allowSet == nil || allowSet!.contains(key))) { filteredPrefs[key] = value } } diff --git a/packages/shared_preferences/shared_preferences_foundation/darwin/Tests/RunnerTests.swift b/packages/shared_preferences/shared_preferences_foundation/darwin/Tests/RunnerTests.swift index 64dd646ef8b5..42a1d00d835b 100644 --- a/packages/shared_preferences/shared_preferences_foundation/darwin/Tests/RunnerTests.swift +++ b/packages/shared_preferences/shared_preferences_foundation/darwin/Tests/RunnerTests.swift @@ -4,14 +4,14 @@ import XCTest +@testable import shared_preferences_foundation + #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #endif -@testable import shared_preferences_foundation - class RunnerTests: XCTestCase { let prefixes: [String] = ["aPrefix", ""] @@ -30,7 +30,7 @@ class RunnerTests: XCTestCase { XCTAssertEqual(storedValues["\(aPrefix)aDouble"] as! Double, 3.14, accuracy: 0.0001) XCTAssertEqual(storedValues["\(aPrefix)anInt"] as? Int, 42) XCTAssertEqual(storedValues["\(aPrefix)aString"] as? String, "hello world") - XCTAssertEqual(storedValues["\(aPrefix)aStringList"] as? Array, ["hello", "world"]) + XCTAssertEqual(storedValues["\(aPrefix)aStringList"] as? [String], ["hello", "world"]) } } @@ -70,40 +70,40 @@ class RunnerTests: XCTestCase { XCTAssertNil(finalValues[testKey] as Any?) } } - - func testClearWithNoAllowlist() throws { - for aPrefix in prefixes { - let plugin = SharedPreferencesPlugin() - let testKey = "\(aPrefix)foo" - plugin.setValue(key: testKey, value: 42) - - // Make sure there is something to clear, so the test can't pass due to a set failure. - let preRemovalValues = plugin.getAll(prefix: aPrefix, allowList: nil) - XCTAssertEqual(preRemovalValues[testKey] as? Int, 42) - - // Then verify that clearing works. - plugin.clear(prefix: aPrefix, allowList: nil) - - let finalValues = plugin.getAll(prefix: aPrefix, allowList: nil) - XCTAssertNil(finalValues[testKey] as Any?) - } + + func testClearWithNoAllowlist() throws { + for aPrefix in prefixes { + let plugin = SharedPreferencesPlugin() + let testKey = "\(aPrefix)foo" + plugin.setValue(key: testKey, value: 42) + + // Make sure there is something to clear, so the test can't pass due to a set failure. + let preRemovalValues = plugin.getAll(prefix: aPrefix, allowList: nil) + XCTAssertEqual(preRemovalValues[testKey] as? Int, 42) + + // Then verify that clearing works. + plugin.clear(prefix: aPrefix, allowList: nil) + + let finalValues = plugin.getAll(prefix: aPrefix, allowList: nil) + XCTAssertNil(finalValues[testKey] as Any?) } - - func testClearWithAllowlist() throws { - for aPrefix in prefixes { - let plugin = SharedPreferencesPlugin() - let testKey = "\(aPrefix)foo" - plugin.setValue(key: testKey, value: 42) - - // Make sure there is something to clear, so the test can't pass due to a set failure. - let preRemovalValues = plugin.getAll(prefix: aPrefix, allowList: nil) - XCTAssertEqual(preRemovalValues[testKey] as? Int, 42) - - plugin.clear(prefix: aPrefix, allowList: ["\(aPrefix)notfoo"]) - - let finalValues = plugin.getAll(prefix: aPrefix, allowList: nil) - XCTAssertEqual(finalValues[testKey] as? Int, 42) - } + } + + func testClearWithAllowlist() throws { + for aPrefix in prefixes { + let plugin = SharedPreferencesPlugin() + let testKey = "\(aPrefix)foo" + plugin.setValue(key: testKey, value: 42) + + // Make sure there is something to clear, so the test can't pass due to a set failure. + let preRemovalValues = plugin.getAll(prefix: aPrefix, allowList: nil) + XCTAssertEqual(preRemovalValues[testKey] as? Int, 42) + + plugin.clear(prefix: aPrefix, allowList: ["\(aPrefix)notfoo"]) + + let finalValues = plugin.getAll(prefix: aPrefix, allowList: nil) + XCTAssertEqual(finalValues[testKey] as? Int, 42) } - + } + } diff --git a/packages/shared_preferences/shared_preferences_foundation/example/ios/Runner/AppDelegate.swift b/packages/shared_preferences/shared_preferences_foundation/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/shared_preferences/shared_preferences_foundation/example/ios/Runner/AppDelegate.swift +++ b/packages/shared_preferences/shared_preferences_foundation/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/two_dimensional_scrollables/example/ios/Runner/AppDelegate.swift b/packages/two_dimensional_scrollables/example/ios/Runner/AppDelegate.swift index caf998393333..d83c0ff0beea 100644 --- a/packages/two_dimensional_scrollables/example/ios/Runner/AppDelegate.swift +++ b/packages/two_dimensional_scrollables/example/ios/Runner/AppDelegate.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { diff --git a/packages/two_dimensional_scrollables/example/macos/RunnerTests/RunnerTests.swift b/packages/two_dimensional_scrollables/example/macos/RunnerTests/RunnerTests.swift index de34867bac24..6a4e9ea78962 100644 --- a/packages/two_dimensional_scrollables/example/macos/RunnerTests/RunnerTests.swift +++ b/packages/two_dimensional_scrollables/example/macos/RunnerTests/RunnerTests.swift @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import FlutterMacOS import Cocoa +import FlutterMacOS import XCTest class RunnerTests: XCTestCase {