我正在使用顫振創建登錄頁面。當用戶單擊登錄按鈕時,用戶沒有意識到他們是否單擊了該按鈕。如何在我的代碼中為按鈕單擊“登錄”添加指示器。感謝您對此的幫助。
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();
}
},
),
)
uj5u.com熱心網友回復:
您可以使用容器和GestureDetector(child: YourTextWidget()). 它有一個輕壓影片。您可以使用 Packageflutter_easyloading來顯示加載圖示。EasyLoading.show(status: "Loading");并停止EasyLoading.dismiss();并顯示結果EasyLoading.showSuccess("Logged In Successfull!");。
uj5u.com熱心網友回復:
GestureDetector(
onTap: () {
Login();
},
child: Text('Log In'),
),
在登錄功能中我們可以使用
login(){
EasyLoading.show(status: "Loading...");
///perform anything you want here.
///and
///show this when you have success
EasyLoading.showSuccess("Logged In Successfully!");
///or this when you dont have success
EasyLoading.showError("Something went wrong");
///and dismiss at last
EasyLoading.dismiss();
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/442299.html
上一篇:無法使用flexbox在HTML表單中居中按鈕-內部代碼
下一篇:是否可以將多個值保存到一個按鈕?
