我在lib / services / authService.dart下定义了一个AuthService类 该类具有1个静态字段和1个静态方法。 但是我无法访问我的lib / screenpage.dart
中的静态字段和方法。我在dartPad中尝试了相同的类,并且运行良好。但是VS Code显示未为类定义方法和获取方法
尝试创建实例变量并设置getter,但是它不起作用
试图重新启动VS代码
class AuthService {
static final FirebaseAuth _auth = FirebaseAuth.instance;
static Future<void> _signInWithEmailAndLink(_userEmail) async => await _auth.sendSignInWithEmailLink(
email: _userEmail,
url: '<Url with domain from your Firebase project>',
);
}
在我的LoginPage.dart内
final auth = await AuthService._auth;
--error ( The getter '_auth' isn't defined for the class 'AuthService'.
Try importing the library that defines '_auth', correcting the name to the name of an existing getter, or defining a getter or field named '_auth')
validationAndLogin() async {
await AuthService._signInWithEmailAndLink(_email);
}
}
The method '_signInWithEmailAndLink' isn't defined for the class 'AuthService'.
Try correcting the name to the name of an existing method, or defining a method named '_signInWithEmailAndLink'.dart(undefine
我不知道在这种情况下我到底想念什么。
答案 0 :(得分:1)