我怎样才能在我的代码中添加重置密码功能
how can i add a reset password function to my code to
我的扑 link github: https://github.com/SpeedyTiger/flutter-app1
这是我的应用程序的 link,希望任何人都可以帮助我为我的 firebase 上的重置密码按钮添加一个功能。
我在这里看到了 link:https://www.back4app.com/docs/flutter/parse-sdk/users/flutter-reset-password
但是没看懂
谢谢!
很简单,在你的控制器中添加这个函数
Future<void> resetPassword({required String email}) async {
try {
return await auth.sendPasswordResetEmail(email: email);
} catch (e) {
print(e); // showError(title: '...', error: e);
}
}
并将 print(e)
替换为 Get.snackbar(...)
。
由于您多次重复使用 Get.snackbar(...)
,我建议您将其重构为它自己的函数,其中有 2 个参数,一个用于标题,另一个用于注释中显示的错误,以保留您的代码干净。
要在小部件中使用:
Button(
isEnabled: controller.isValidEmail.value,
height: 55.0,
text: 'Reset Password',
child: auth.isReseting.value ? const PAIndicator() : null,
onTap: () async => await Services.auth.resetPassword(email: email),
),
我的扑 link github: https://github.com/SpeedyTiger/flutter-app1
这是我的应用程序的 link,希望任何人都可以帮助我为我的 firebase 上的重置密码按钮添加一个功能。
我在这里看到了 link:https://www.back4app.com/docs/flutter/parse-sdk/users/flutter-reset-password
但是没看懂
谢谢!
很简单,在你的控制器中添加这个函数
Future<void> resetPassword({required String email}) async {
try {
return await auth.sendPasswordResetEmail(email: email);
} catch (e) {
print(e); // showError(title: '...', error: e);
}
}
并将 print(e)
替换为 Get.snackbar(...)
。
由于您多次重复使用 Get.snackbar(...)
,我建议您将其重构为它自己的函数,其中有 2 个参数,一个用于标题,另一个用于注释中显示的错误,以保留您的代码干净。
要在小部件中使用:
Button(
isEnabled: controller.isValidEmail.value,
height: 55.0,
text: 'Reset Password',
child: auth.isReseting.value ? const PAIndicator() : null,
onTap: () async => await Services.auth.resetPassword(email: email),
),