Use final state passed to dart before initialization as the initial lifecycleState. (flutter/engine#8124)

This commit is contained in:
Gary Qian
2019-03-12 10:35:08 -07:00
committed by GitHub
parent d8ab06e733
commit e2b873f0a5
2 changed files with 12 additions and 2 deletions

View File

@@ -92,7 +92,10 @@ void _updateUserSettingsData(String jsonData) {
@pragma('vm:entry-point')
// ignore: unused_element
void _updateLifecycleState(String state) {
window._initialLifecycleState ??= state;
// We do not update the state if the state has already been used to initialize
// the lifecycleState.
if (!window._initialLifecycleStateAccessed)
window._initialLifecycleState = state;
}

View File

@@ -562,8 +562,15 @@ class Window {
///
/// It is used to initialize [SchedulerBinding.lifecycleState] at startup
/// with any buffered lifecycle state events.
String get initialLifecycleState => _initialLifecycleState;
String get initialLifecycleState {
_initialLifecycleStateAccessed = true;
return _initialLifecycleState;
}
String _initialLifecycleState;
/// Tracks if the initial state has been accessed. Once accessed, we
/// will stop updating the [initialLifecycleState], as it is not the
/// preferred way to access the state.
bool _initialLifecycleStateAccessed = false;
/// The system-reported text scale.
///