Skip to content

Commit 84fe3b6

Browse files
Revert "Update FocusManager platform check to include iOS" (#148978)
1 parent 8d955cd commit 84fe3b6

2 files changed

Lines changed: 7 additions & 24 deletions

File tree

packages/flutter/lib/src/widgets/focus_manager.dart

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,21 +1532,12 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
15321532
if (kFlutterMemoryAllocationsEnabled) {
15331533
ChangeNotifier.maybeDispatchObjectCreation(this);
15341534
}
1535-
final bool shouldListenToAppLifecycle = switch (defaultTargetPlatform) {
1536-
TargetPlatform.android || TargetPlatform.iOS => false,
1537-
TargetPlatform.fuchsia || TargetPlatform.linux => true,
1538-
TargetPlatform.windows || TargetPlatform.macOS => true,
1539-
};
1540-
if (shouldListenToAppLifecycle) {
1535+
if (kIsWeb || defaultTargetPlatform != TargetPlatform.android) {
15411536
// It appears that some Android keyboard implementations can cause
15421537
// app lifecycle state changes: adding this listener would cause the
15431538
// text field to unfocus as the user is trying to type.
15441539
//
1545-
// Additionally, on iOS, input fields aren't automatically populated
1546-
// with relevant data when using autofill.
1547-
//
1548-
// Until these are resolved, we won't be adding the listener to mobile platforms.
1549-
// https://github.com/flutter/flutter/issues/148475#issuecomment-2118407411
1540+
// Until this is resolved, we won't be adding the listener to Android apps.
15501541
// https://github.com/flutter/flutter/pull/142930#issuecomment-1981750069
15511542
_appLifecycleListener = _AppLifecycleListener(_appLifecycleChange);
15521543
WidgetsBinding.instance.addObserver(_appLifecycleListener!);

packages/flutter/test/widgets/focus_manager_test.dart

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,9 @@ void main() {
354354
logs.clear();
355355
}, variant: KeySimulatorTransitModeVariant.all());
356356

357-
testWidgets('FocusManager ignores app lifecycle changes on Android and iOS.', (WidgetTester tester) async {
358-
final bool shouldListenToAppLifecycle = switch (defaultTargetPlatform) {
359-
TargetPlatform.android || TargetPlatform.iOS => false,
360-
TargetPlatform.fuchsia || TargetPlatform.linux => true,
361-
TargetPlatform.windows || TargetPlatform.macOS => true,
362-
};
363-
if (shouldListenToAppLifecycle) {
357+
testWidgets('FocusManager ignores app lifecycle changes on Android.', (WidgetTester tester) async {
358+
final bool shouldRespond = kIsWeb || defaultTargetPlatform != TargetPlatform.android;
359+
if (shouldRespond) {
364360
return;
365361
}
366362

@@ -391,12 +387,8 @@ void main() {
391387
});
392388

393389
testWidgets('FocusManager responds to app lifecycle changes.', (WidgetTester tester) async {
394-
final bool shouldListenToAppLifecycle = switch (defaultTargetPlatform) {
395-
TargetPlatform.android || TargetPlatform.iOS => false,
396-
TargetPlatform.fuchsia || TargetPlatform.linux => true,
397-
TargetPlatform.windows || TargetPlatform.macOS => true,
398-
};
399-
if (!shouldListenToAppLifecycle) {
390+
final bool shouldRespond = kIsWeb || defaultTargetPlatform != TargetPlatform.android;
391+
if (!shouldRespond) {
400392
return;
401393
}
402394

0 commit comments

Comments
 (0)