如何在flutter android中实现自动填充提示?

问题描述 投票:0回答:1

在 iOS 中工作正常,但在 Android 中却无法工作

 Form(
                              key: formKey,
                              child: AutofillGroup(
                                child: Column(
                                  children: [
                                    Row(
                                      children: [
                                        Flexible(
                                          child: Text(
                                            'Login',
                                            style: GoogleFonts.montserrat(
                                                color: whiteColor,
                                                fontWeight: FontWeight.w600,
                                                fontSize: 40.sp),
                                          ),
                                        ),
                                      ],
                                    ),
                                    const SizedBox(
                                      height: 30,
                                    ),
                                    TextFormField(
                                      enableSuggestions: true,
                                      autofillHints: const [
                                        AutofillHints.username
                                      ],
                                      controller: loginController
                                          .userNameEditingController,
                                      keyboardType: TextInputType.emailAddress,
                                      decoration: InputDecoration(
                                        hintText: 'Enter user name',
                                        hintStyle: GoogleFonts.montserrat(
                                            fontSize: 14.sp,
                                            fontWeight: FontWeight.w500),
                                        errorStyle: GoogleFonts.rubik(
                                            color: whiteColor),
                                        errorBorder: OutlineInputBorder(
                                            borderRadius:
                                                BorderRadius.circular(40),
                                            borderSide: const BorderSide(
                                                width: 3,
                                                color: Color.fromARGB(
                                                    255, 255, 33, 33))),

                                        filled: true,
                                        fillColor: Colors.white,
                                        border: OutlineInputBorder(
                                            borderSide: BorderSide.none,
                                            borderRadius:
                                                BorderRadius.circular(40)),
                                        contentPadding: const EdgeInsets.only(
                                            right: 20,
                                            left: 25,
                                            top: 20,
                                            bottom: 20),
                                        // contentPadding: const EdgeInsets
                                        //     .symmetric(
                                        //     horizontal: 20,
                                        //     vertical:
                                        //         10), // Adjust padding as needed
                                      ),
                                      style: const TextStyle(
                                          color: Colors.black), // Text color

                                      validator: (value) {
                                        if (value!.length < 3) {
                                          return "Please enter valid username";
                                        }
                                        return null;
                                      },
                                    ),
                                    SizedBox(
                                      height: 12.h,
                                    ),
                                    GetBuilder<LoginController>(
                                        builder: (context) {
                                      return TextFormField(
                                        autofillHints: const [
                                          AutofillHints.password
                                        ],
                                        focusNode: _focusNode1,
                                        obscureText: loginController.viewPass,
                                        controller: loginController
                                            .passwordEditingController,
                                        decoration: InputDecoration(
                                          contentPadding: const EdgeInsets.only(
                                              right: 20,
                                              left: 25,
                                              top: 20,
                                              bottom: 20),
                                          suffixIcon: InkWell(
                                              onTap: () {
                                                loginController.viewPassword();
                                              },
                                              child: Icon(
                                                Icons.remove_red_eye,
                                                color: loginController.viewPass
                                                    ? Colors.grey
                                                    : loginContainerColor,
                                              )),
                                          errorStyle: GoogleFonts.rubik(
                                              color: whiteColor),
                                          errorBorder: OutlineInputBorder(
                                              borderRadius:
                                                  BorderRadius.circular(40),
                                              borderSide: const BorderSide(
                                                  width: 3,
                                                  color: Color.fromARGB(
                                                      255, 255, 33, 33))),
                                          hintText: '*********',
                                          filled: true,
                                          fillColor: Colors.white,
                                          border: OutlineInputBorder(
                                              borderSide: BorderSide.none,
                                              borderRadius:
                                                  BorderRadius.circular(40)),
                                          // contentPadding: const EdgeInsets
                                          //     .symmetric(
                                          //     horizontal: 20,
                                          //     vertical:
                                          //         10), // Adjust padding as needed
                                        ),

                                        style: const TextStyle(
                                            color: Colors.black), // Text color
                                        validator: (value) {
                                          if (value!.isEmpty) {
                                            return "Please enter valid password";
                                          }
                                          return null;
                                        },
                                      );
                                    }),
                                    SizedBox(
                                      height: 27.h,
                                    ),
                                    ShakeMe(
                                      key: shakeKey,
                                      shakeCount: 3,
                                      shakeOffset: 10,
                                      shakeDuration:
                                          const Duration(milliseconds: 500),
                                      child: Obx(() {
                                        return ElevatedButton(
                                            style: ButtonStyle(
                                                side: const MaterialStatePropertyAll(
                                                    BorderSide(
                                                        color: whiteColor,
                                                        width: .3)),
                                                fixedSize:
                                                    MaterialStatePropertyAll(
                                                        Size(380.w, 66.h)),
                                                backgroundColor:
                                                    const MaterialStatePropertyAll(
                                                        Color.fromARGB(
                                                            255, 202, 30, 44))),
                                            onPressed: loginController
                                                    .isLoginLoading.value
                                                ? null
                                                : () {
                                                    // Get.offAll(() => const BottombarView(),
                                                    //     transition: Transition.fade,
                                                    //     duration: const Duration(seconds: 2));
                                                    //     transition: Transition.cupertino);
                                                    // Navigator.popUntil(context, (route) => false);
                                                    // Navigator.pushNamed(context, ('/bottomBar'));
                                                    if ((formKey.currentState!
                                                        .validate())) {
                                                      // loginController
                                                      //     .saveCredentials();
                                                      loginController
                                                          .loginFunct(context,
                                                              shakeKey);
                                                    } else {
                                                      loginController
                                                          .shakeWidget(
                                                              shakeKey);
                                                    }
                                                  },
                                            child: loginController
                                                    .isLoginLoading.value
                                                ? SpinKitFadingFour(
                                                    size: 40,
                                                    color: const Color.fromARGB(
                                                        219, 255, 255, 255),
                                                    controller: _controller,
                                                  )
                                                : Text("Login",
                                                    style: GoogleFonts.montserrat(
                                                        color: whiteColor,
                                                        fontWeight:
                                                            FontWeight.w500,
                                                        fontSize: 16)));
                                      }),
                                    ),
                                    SizedBox(
                                      height: 27.h,
                                    ),
                                    Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        InkWell(
                                          onTap: () {
                                            Get.to(
                                                const RequestStatementView());
                                          },
                                          child: Text(
                                            "Not yet member ?",
                                            style: GoogleFonts.rubik(
                                                color: whiteColor,
                                                decoration:
                                                    TextDecoration.underline,
                                                decorationColor: whiteColor),
                                          ),
                                        ),
                                        InkWell(
                                          onTap: () {
                                            Get.to(
                                                () => ForgotPasswordView(
                                                      loginController:
                                                          loginController,
                                                    ),
                                                transition:
                                                    Transition.cupertino);
                                          },
                                          child: Text(
                                            "Forgot Password ?",
                                            style: GoogleFonts.rubik(
                                                color: whiteColor,
                                                decoration:
                                                    TextDecoration.underline,
                                                decorationColor: whiteColor),
                                          ),
                                        ),
                                      ],
                                    ),
                                    SizedBox(
                                      height: 66.h,
                                    ),
                                    SizedBox(
                                        height: 13,
                                        width: 100.w,
                                        child: Image.asset(
                                          "assets/images/starting page/divergent.png",
                                        )),
                                    const SizedBox(
                                      height: 15,
                                    ),
                                    Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      children: [
                                        Flexible(
                                          child: Text(
                                            "Copyright © 2024 . All right reserved.\nDivergent Line HR Consultants LLC",
                                            textAlign: TextAlign.center,
                                            style: GoogleFonts.montserrat(
                                                fontSize: 11.sp,
                                                fontWeight: FontWeight.w300,
                                                color: whiteColor),
                                          ),
                                        )
                                      ],
                                    ),
                                  ],
                                ),
                              ),
                            ),
flutter dart passwords autofill
1个回答
0
投票

基于自动填充文档

支持自动填充的最低平台 SDK 版本为 Android 的 API 级别 26,以及 iOS 的 iOS 10.0。

确保您的 Android 应用程序使用正确的 SDK 版本。

您可能还需要在 Android 手机的设置中启用自动填充服务:

Android 自动填充:前往“设置”->“系统”->“语言和输入法”->“自动填充服务”。启用您选择的自动填充服务,并确保有与您的应用程序关联的可用凭据。

© www.soinside.com 2019 - 2024. All rights reserved.