diff --git a/packages/flutter/lib/src/widgets/focus_manager.dart b/packages/flutter/lib/src/widgets/focus_manager.dart index eb6eebf10b8ae292a03c4dae9435fddeb6c2b882..a02479a5ea55159e4fcea8c4437a00d41514045e 100644 --- a/packages/flutter/lib/src/widgets/focus_manager.dart +++ b/packages/flutter/lib/src/widgets/focus_manager.dart @@ -1521,13 +1521,15 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier { if (kFlutterMemoryAllocationsEnabled) { ChangeNotifier.maybeDispatchObjectCreation(this); } - if (kIsWeb || defaultTargetPlatform != TargetPlatform.android) { + if (kIsWeb || (defaultTargetPlatform != TargetPlatform.android && defaultTargetPlatform != TargetPlatform.ohos)) { // It appears that some Android keyboard implementations can cause // app lifecycle state changes: adding this listener would cause the // text field to unfocus as the user is trying to type. // // Until this is resolved, we won't be adding the listener to Android apps. // https://github.com/flutter/flutter/pull/142930#issuecomment-1981750069 + // On the OHOS platform, any operations on the keyboard are ineffective when the app loses focus, + // making it unsuitable to listen to the application lifecycle. _appLifecycleListener = _AppLifecycleListener(_appLifecycleChange); WidgetsBinding.instance.addObserver(_appLifecycleListener!); }