Skip to content

Autofill save (TextInput.finishAutofillContext) not working #104071

@NikosTsesmelis

Description

@NikosTsesmelis

Calling TextInput.finishAutofillContext does not show the save dialog.

Tested in Android and IOS.

Saving credit card info works only in Android.

Saving email - password doesn't work.

Here is the flutter doctor:

[✓] Flutter (Channel stable, 3.0.0, on macOS 12.3.1 21E258 darwin-arm, locale en-GR)
    • Flutter version 3.0.0 at /Users/nikostsesmelis/Tools/flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (9 days ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2

Here is an example:

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class TestScreen extends StatelessWidget {
  const TestScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: ListView(
          padding: const EdgeInsets.all(16),
          children: [
            AutofillGroup(
              child: Column(
                children: [
                  const TextField(
                    keyboardType: TextInputType.emailAddress,
                    decoration: const InputDecoration(hintText: 'enter email'),
                    autofillHints: [AutofillHints.username, AutofillHints.newUsername, AutofillHints.email],
                  ),
                  const SizedBox(height: 16),
                  const TextField(
                    keyboardType: TextInputType.visiblePassword,
                    decoration: InputDecoration(hintText: 'enter password'),
                    autofillHints: [AutofillHints.password, AutofillHints.newPassword],
                  ),
                  const SizedBox(height: 16),
                  GestureDetector(
                    onTap: TextInput.finishAutofillContext,
                    child: Container(
                      color: Colors.red,
                      padding: const EdgeInsets.all(16),
                      child: const Text('SAVE CREDENTIALS'),
                    ),
                  ),
                ],
              ),
            ),
            const SizedBox(height: 16),
            AutofillGroup(
              child: Column(
                children: [
                  const TextField(
                    keyboardType: TextInputType.number,
                    decoration: const InputDecoration(hintText: 'enter credit card number'),
                    autofillHints: [AutofillHints.creditCardNumber],
                  ),
                  const SizedBox(height: 16),
                  const TextField(
                    keyboardType: TextInputType.text,
                    decoration: InputDecoration(hintText: 'enter credit card date'),
                    autofillHints: [AutofillHints.creditCardExpirationDate],
                  ),
                  const TextField(
                    keyboardType: TextInputType.number,
                    decoration: InputDecoration(hintText: 'enter credit card cvv'),
                    autofillHints: [AutofillHints.creditCardSecurityCode],
                  ),
                  const TextField(
                    keyboardType: TextInputType.name,
                    decoration: InputDecoration(hintText: 'enter credit card name'),
                    autofillHints: [AutofillHints.creditCardName],
                  ),
                  const SizedBox(height: 16),
                  GestureDetector(
                    onTap: TextInput.finishAutofillContext,
                    child: Container(
                      color: Colors.red,
                      padding: const EdgeInsets.all(16),
                      child: const Text('SAVE CREDIT CARD'),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions