| Flutter macOS Embedder |

app_lifecycle_state.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_COMMON_APP_LIFECYCLE_STATE_H_
6 #define FLUTTER_SHELL_PLATFORM_COMMON_APP_LIFECYCLE_STATE_H_
7
8 namespace flutter {
9
10 /**
11 * These constants describe the possible lifecycle states of the application.
12 * They must be kept up to date with changes in the framework's
13 * AppLifecycleState enum. They are passed to the embedder's |SetLifecycleState|
14 * function.
15 *
16 * States not supported on a platform will be synthesized by the framework when
17 * transitioning between states which are supported, so that all implementations
18 * share the same state machine.
19 *
20 * Here is the state machine:
21 *
22 * +-----------+ +-----------+
23 * | detached |------------------------------>| resumed |
24 * +-----------+ +-----------+
25 * ^ ^
26 * | |
27 * | v
28 * +-----------+ +--------------+ +-----------+
29 * | paused |<------>| hidden |<----->| inactive |
30 * +-----------+ +--------------+ +-----------+
31 */
32 enum class AppLifecycleState {
33 /**
34 * Corresponds to the Framework's AppLifecycleState.detached: The initial
35 * state of the state machine. On Android and iOS, also the final state of the
36 * state machine when all views are detached. Other platforms do not enter
37 * this state again after initially leaving it.
38 */
39 kDetached,
40
41 /**
42 * Corresponds to the Framework's AppLifecycleState.resumed: The nominal
43 * "running" state of the application. The application is visible, has input
44 * focus, and is running.
45 */
46 kResumed,
47
48 /**
49 * Corresponds to the Framework's AppLifecycleState.inactive: At least one
50 * view of the application is visible, but none have input focus. The
51 * application is otherwise running normally.
52 */
53 kInactive,
54
55 /**
56 * Corresponds to the Framework's AppLifecycleState.hidden: All views of an
57 * application are hidden, either because the application is being stopped (on
58 * iOS and Android), or because it is being minimized or on a desktop that is
59 * no longer visible (on desktop), or on a tab that is no longer visible (on
60 * web).
61 */
62 kHidden,
63
64 /**
65 * Corresponds to the Framework's AppLifecycleState.paused: The application is
66 * not running, and can be detached or started again at any time. This state
67 * is typically only entered into on iOS and Android.
68 */
69 kPaused,
70 };
71
72 constexpr const char* AppLifecycleStateToString(AppLifecycleState state) {
73 switch (state) {
74 case AppLifecycleState::kDetached:
75 return "AppLifecycleState.detached";
76 case AppLifecycleState::kResumed:
77 return "AppLifecycleState.resumed";
78 case AppLifecycleState::kInactive:
79 return "AppLifecycleState.inactive";
80 case AppLifecycleState::kHidden:
81 return "AppLifecycleState.hidden";
82 case AppLifecycleState::kPaused:
83 return "AppLifecycleState.paused";
84 }
85 }
86
87 } // namespace flutter
88
89 #endif // FLUTTER_SHELL_PLATFORM_COMMON_APP_LIFECYCLE_STATE_H_
flutter::AppLifecycleState::kHidden
@ kHidden
flutter::AppLifecycleState::kInactive
@ kInactive
flutter
Definition: AccessibilityBridgeMac.h:16
flutter::AppLifecycleState::kResumed
@ kResumed
flutter::AppLifecycleState::kDetached
@ kDetached
flutter::AppLifecycleState
AppLifecycleState
Definition: app_lifecycle_state.h:32
flutter::AppLifecycleStateToString
constexpr const char * AppLifecycleStateToString(AppLifecycleState state)
Definition: app_lifecycle_state.h:72
flutter::AppLifecycleState::kPaused
@ kPaused