【发布时间】:2018-10-12 04:34:45
【问题描述】:
我正在尝试创建一个包含特定身份验证过程内部方法的类
所以我创建了一个文件 MyAuthMethods.dart
class UserAuth {
static int seconds = 10000000;
static String username;
static String password;
static String key = "abc123";
static Future<String> _generateAuthCode(seconds, username, password, key) async{
var result = "something";
print("Seconds: seconds, Username: username, Password: password, Key: key");
return result;
}
}
在我的表单 (FormScreen.dart) 上,有一个按钮 onPressed 来执行该功能
onPressed:(){
UserAuth._generateAuthCode(UserAuth.seconds, "username", "password", UserAuth.key);
}
但它不起作用。它说:
error: The method '_generateAuthCode' isn't defined for the class 'UserAuth'.
我需要改变什么?
【问题讨论】: