Ali Bakhtiyari
Ali Bakhtiyari

Reputation: 332

Flutter Autofill on Login Form closes keyboard after Inserting first character on Samsung Galaxy with Samsung Pass

When I run the provided sample app (contains a Form and AutofillGroup) on a Samsung device with Samsung Pass as Autofill service, after the first character is entered and Samsung pass doesn't have any suggestion that starts with it, the keyboard suddenly dismisses.

Run this code on Samsung device with Samsung Pass enabled:

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Auto Fill Issue'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Form(
              child: AutofillGroup(
                child: Column(
                  children: [
                    TextFormField(
                      autocorrect: false,
                      keyboardType: TextInputType.emailAddress,
                      autofillHints: const [AutofillHints.email],
                      autovalidateMode: AutovalidateMode.onUserInteraction,
                    ),
                    TextFormField(
                      autocorrect: false,
                      keyboardType: TextInputType.text,
                      autofillHints: const [AutofillHints.password],
                      autovalidateMode: AutovalidateMode.onUserInteraction,
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: const FloatingActionButton(
        onPressed: TextInput.finishAutofillContext,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

Also this is flutter doctor command output:

[✓] Flutter (Channel stable, 3.19.1, on macOS 14.3 23D56 darwin-arm64)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.2)
    ✗ Unable to get list of installed Simulator runtimes.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.86.0)
[✓] Connected device (3 available)            
[✓] Network resources

I selected Google as an autofill service on Pixel Simulator, everything was fine and the issue did not happen. I updated the Samsung Pass App to the latest version and the issue persisted. The Samsung Pass is mandatory on Galaxy devices, unfortunately, it didn't have the option to disable it from settings, which means our users who have Samsung devices will encounter this issue.

Upvotes: 2

Views: 201

Answers (0)

Related Questions