| Flutter macOS Embedder |

FlutterAppDelegate.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_HEADERS_FLUTTERAPPDELEGATE_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_HEADERS_FLUTTERAPPDELEGATE_H_
7
8 #import <Cocoa/Cocoa.h>
9
10 #import "FlutterAppLifecycleDelegate.h"
11 #import "FlutterMacros.h"
12
13 /**
14 * A protocol to be implemented by the `NSApplicationDelegate` of an application to enable the
15 * Flutter framework and any Flutter plugins to register to receive application life cycle events.
16 *
17 * Implementers should forward all of the `NSApplicationDelegate` methods corresponding to the
18 * handlers in FlutterAppLifecycleDelegate to any registered delegates.
19 */
20 FLUTTER_DARWIN_EXPORT
21 @protocol FlutterAppLifecycleProvider <NSObject>
22
23 /**
24 * Adds an object implementing |FlutterAppLifecycleDelegate| to the list of
25 * delegates to be informed of application lifecycle events.
26 */
27 - (void)addApplicationLifecycleDelegate:(nonnull NSObject<FlutterAppLifecycleDelegate>*)delegate;
28
29 /**
30 * Removes an object implementing |FlutterAppLifecycleDelegate| to the list of
31 * delegates to be informed of application lifecycle events.
32 */
33 - (void)removeApplicationLifecycleDelegate:(nonnull NSObject<FlutterAppLifecycleDelegate>*)delegate;
34
35 @end
36
37 /**
38 * |NSApplicationDelegate| subclass for simple apps that want default behavior.
39 *
40 * This class implements the following behaviors:
41 * * Updates the application name of items in the application menu to match the name in
42 * the app's Info.plist, assuming it is set to APP_NAME initially. |applicationMenu| must be
43 * set before the application finishes launching for this to take effect.
44 * * Updates the main Flutter window's title to match the name in the app's Info.plist.
45 * |mainFlutterWindow| must be set before the application finishes launching for this to take
46 * effect.
47 * * Forwards `NSApplicationDelegate` callbacks to plugins that register for them.
48 *
49 * App delegates for Flutter applications are *not* required to inherit from
50 * this class. Developers of custom app delegate classes should copy and paste
51 * code as necessary from FlutterAppDelegate.mm.
52 */
53 FLUTTER_DARWIN_EXPORT
54 @interface FlutterAppDelegate : NSObject <NSApplicationDelegate, FlutterAppLifecycleProvider>
55
56 /**
57 * The application menu in the menu bar.
58 */
59 @property(weak, nonatomic, nullable) IBOutlet NSMenu* applicationMenu;
60
61 /**
62 * The primary application window containing a FlutterViewController. This is
63 * primarily intended for use in single-window applications.
64 */
65 @property(weak, nonatomic, nullable) IBOutlet NSWindow* mainFlutterWindow;
66
67 @end
68
69 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_HEADERS_FLUTTERAPPDELEGATE_H_
FlutterMacros.h
FlutterAppLifecycleProvider-p
Definition: FlutterAppDelegate.h:21
FlutterAppLifecycleDelegate-p
Definition: FlutterAppLifecycleDelegate.h:21
FlutterAppDelegate
Definition: FlutterAppDelegate.h:54
FlutterAppDelegate::mainFlutterWindow
IBOutlet NSWindow * mainFlutterWindow
Definition: FlutterAppDelegate.h:65
FlutterAppDelegate::applicationMenu
IBOutlet NSMenu * applicationMenu
Definition: FlutterAppDelegate.h:59
FLUTTER_DARWIN_EXPORT
#define FLUTTER_DARWIN_EXPORT
Definition: FlutterMacros.h:14
FlutterAppLifecycleDelegate.h