Flutter autofill not working with latest SDK

Viewed 149

I'm working on a form in which I want to have the functionality for autofill.

Unfortunately, I'm trying to use the AutofillGroup widget with TextField or TextFormField with autofillHints setup but they don't work on both emulator and real device.

I'm using Flutter SDK 2.10.0

 @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(controller: repeatNewPassword, autofillHints: [AutofillHints.newPassword]),
          if (!isNewUser) TextField(controller: password, autofillHints: [AutofillHints.password]),
        ],
      ),
    );
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: AutofillGroup(
        child: Container(
          padding: EdgeInsets.only(top: 50),
          child: Column(
            children: <Widget>[
              TextFormField(
                  controller: username,
                  autofillHints: [AutofillHints.username]),
              TextFormField(
                  controller: newPassword,
                  autofillHints: [AutofillHints.newPassword]),
            ],
          ),
        ),
      ),
    );
  }
0 Answers
Related