@@ -24,18 +24,17 @@ public final class QuickActionsPlugin: NSObject, FlutterPlugin {
24
24
@objc
25
25
public init (
26
26
channel: FlutterMethodChannel ,
27
- shortcutStateManager: FLTShortcutStateManager = FLTShortcutStateManager ( ) )
28
- {
27
+ shortcutStateManager: FLTShortcutStateManager = FLTShortcutStateManager ( )
28
+ ) {
29
29
self . channel = channel
30
30
self . shortcutStateManager = shortcutStateManager
31
31
}
32
32
33
33
public func handle( _ call: FlutterMethodCall , result: @escaping FlutterResult ) {
34
34
switch call. method {
35
35
case " setShortcutItems " :
36
- guard let items = call. arguments as? [ [ String : Any ] ] else {
37
- preconditionFailure ( " The argument must be a list of dictionaries " )
38
- }
36
+ // `arguments` must be a list of dictionaries
37
+ let items = call. arguments as! [ [ String : Any ] ]
39
38
shortcutStateManager. setShortcutItems ( items)
40
39
result ( nil )
41
40
case " clearShortcutItems " :
@@ -48,13 +47,21 @@ public final class QuickActionsPlugin: NSObject, FlutterPlugin {
48
47
}
49
48
}
50
49
51
- public func application( _ application: UIApplication , performActionFor shortcutItem: UIApplicationShortcutItem , completionHandler: @escaping ( Bool ) -> Void ) -> Bool {
50
+ public func application(
51
+ _ application: UIApplication , performActionFor shortcutItem: UIApplicationShortcutItem ,
52
+ completionHandler: @escaping ( Bool ) -> Void
53
+ ) -> Bool {
52
54
handleShortcut ( shortcutItem. type)
53
55
return true
54
56
}
55
57
56
- public func application( _ application: UIApplication , didFinishLaunchingWithOptions launchOptions: [ AnyHashable : Any ] = [ : ] ) -> Bool {
57
- if let shortcutItem = launchOptions [ UIApplication . LaunchOptionsKey. shortcutItem] as? UIApplicationShortcutItem {
58
+ public func application(
59
+ _ application: UIApplication ,
60
+ didFinishLaunchingWithOptions launchOptions: [ AnyHashable : Any ] = [ : ]
61
+ ) -> Bool {
62
+ if let shortcutItem = launchOptions [ UIApplication . LaunchOptionsKey. shortcutItem]
63
+ as? UIApplicationShortcutItem
64
+ {
58
65
// Keep hold of the shortcut type and handle it in the
59
66
// `applicationDidBecomeActure:` method once the Dart MethodChannel
60
67
// is initialized.
@@ -63,7 +70,7 @@ public final class QuickActionsPlugin: NSObject, FlutterPlugin {
63
70
// Return false to indicate we handled the quick action to ensure
64
71
// the `application:performActionFor:` method is not called (as
65
72
// per Apple's documentation:
66
- // https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622935-application?language=objc ).
73
+ // https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622935-application).
67
74
return false
68
75
}
69
76
return true
0 commit comments