Revert "Update FocusManager platform check to include iOS" (#148978)
This commit is contained in:
@@ -1532,21 +1532,12 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
|
||||
if (kFlutterMemoryAllocationsEnabled) {
|
||||
ChangeNotifier.maybeDispatchObjectCreation(this);
|
||||
}
|
||||
final bool shouldListenToAppLifecycle = switch (defaultTargetPlatform) {
|
||||
TargetPlatform.android || TargetPlatform.iOS => false,
|
||||
TargetPlatform.fuchsia || TargetPlatform.linux => true,
|
||||
TargetPlatform.windows || TargetPlatform.macOS => true,
|
||||
};
|
||||
if (shouldListenToAppLifecycle) {
|
||||
if (kIsWeb || defaultTargetPlatform != TargetPlatform.android) {
|
||||
// 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.
|
||||
//
|
||||
// Additionally, on iOS, input fields aren't automatically populated
|
||||
// with relevant data when using autofill.
|
||||
//
|
||||
// Until these are resolved, we won't be adding the listener to mobile platforms.
|
||||
// https://github.com/flutter/flutter/issues/148475#issuecomment-2118407411
|
||||
// Until this is resolved, we won't be adding the listener to Android apps.
|
||||
// https://github.com/flutter/flutter/pull/142930#issuecomment-1981750069
|
||||
_appLifecycleListener = _AppLifecycleListener(_appLifecycleChange);
|
||||
WidgetsBinding.instance.addObserver(_appLifecycleListener!);
|
||||
|
||||
@@ -354,13 +354,9 @@ void main() {
|
||||
logs.clear();
|
||||
}, variant: KeySimulatorTransitModeVariant.all());
|
||||
|
||||
testWidgets('FocusManager ignores app lifecycle changes on Android and iOS.', (WidgetTester tester) async {
|
||||
final bool shouldListenToAppLifecycle = switch (defaultTargetPlatform) {
|
||||
TargetPlatform.android || TargetPlatform.iOS => false,
|
||||
TargetPlatform.fuchsia || TargetPlatform.linux => true,
|
||||
TargetPlatform.windows || TargetPlatform.macOS => true,
|
||||
};
|
||||
if (shouldListenToAppLifecycle) {
|
||||
testWidgets('FocusManager ignores app lifecycle changes on Android.', (WidgetTester tester) async {
|
||||
final bool shouldRespond = kIsWeb || defaultTargetPlatform != TargetPlatform.android;
|
||||
if (shouldRespond) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -391,12 +387,8 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('FocusManager responds to app lifecycle changes.', (WidgetTester tester) async {
|
||||
final bool shouldListenToAppLifecycle = switch (defaultTargetPlatform) {
|
||||
TargetPlatform.android || TargetPlatform.iOS => false,
|
||||
TargetPlatform.fuchsia || TargetPlatform.linux => true,
|
||||
TargetPlatform.windows || TargetPlatform.macOS => true,
|
||||
};
|
||||
if (!shouldListenToAppLifecycle) {
|
||||
final bool shouldRespond = kIsWeb || defaultTargetPlatform != TargetPlatform.android;
|
||||
if (!shouldRespond) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user