如何将单击的指示器按钮添加到我的登录按钮



我正在使用颤振创建一个登录页面。 当用户单击登录按钮时,用户没有意识到他们是否单击了该按钮。 如何为按钮添加指示器 在我的代码中单击"登录"。 感谢您对此的帮助。

class _LoginFormState extends State<LoginForm> {
final _formKey = GlobalKey<FormState>();
String email = "";
String password = "";

Future LoginData() async {
try {
var response = await Dio().post(BASE_API+'user/Login',
data: {"email": email, "password": password});

if (response.data["message"] == "logged in successfully") {
Get.snackbar("success", "logged in successfully");
Get.to(HomeScreen());

} else {
Get.snackbar(
"error",
"No User Found",
// backgroundColor: heartRed.withOpacity(0.8),
// colorText: textWhite,
);
}
print("res: $response");
} catch (e) {
Get.snackbar("Error", "Something went wrong.Please contact admin",
backgroundColor: textWhite.withOpacity(0.5),
borderWidth: 1,
borderColor: textGrey,
colorText: textGrey,
icon: Icon(
Icons.error_outline_outlined,
color: heartRed,
size: 30,
));
print(e);
}
}
Container(
padding: const EdgeInsets.all(20.0),
child: GestureDetector(
child: ButtonM("Login"),
onTap: () async {
if (_formKey.currentState!.validate()){
LoginData();
}
},
),
)

您可以使用容器并GestureDetector(child: YourTextWidget()).它有一个轻描淡写的动画。您可以使用包flutter_easyloading显示加载图标。EasyLoading.show(status: "Loading");并停止EasyLoading.dismiss();并显示结果EasyLoading.showSuccess("Logged In Successfull!");

最新更新