Gabeloooooo
Gabeloooooo

Reputation: 675

Password manager (autofill) integration in Flutter

Is there a simple way to integrate password autofill (like lastpass) in a flutter TextField?

Upvotes: 6

Views: 3583

Answers (1)

MαπμQμαπkγVπ.0
MαπμQμαπkγVπ.0

Reputation: 6729

Flutter now supports autofill (password, email, username, etc.). There is an existing GitHub ticket about text fields trigger to support autofill and is now closed. Check this thread, for the merged PR with example.

This PR (as well as the engine PRs) adds the most basic autofill functionality. It does not include some platform-specific configurations (e.g., passwordRules on iOS).

  @override
  Widget build(BuildContext context) {
    return AutofillGroup(
      child: Column(
        children: <Widget>[
          TextField(controller: username, autofillHints: [AutofillHints.username]),
          Checkbox(
            value: isNewUser,
            onChanged: (bool newValue) {
              setState(() { isNewUser = newValue; });
            },
          ),
          if (isNewUser) TextField(controller: newPassword, autofillHints: [AutofillHints.newPassword]),
          if (isNewUser) TextField(ontroller: repeatNewPassword, autofillHints: [AutofillHints.newPassword]),
          if (!isNewUser) TextField(controller: password, autofillHints: [AutofillHints.password]),
        ],
      ),
    );
  }

But if you are specifically looking for LastPass support, this is a Flutter limitation atm. There is a ticket filed in GitHub regarding this issue.

Upvotes: 3

Related Questions