[英]How to use enum in flutter?
I am making a Flutter app in which you can sign in with a Google Account.我正在制作一个 Flutter 应用程序,您可以在其中使用 Google 帐户登录。 I would like to add this enum to the program:我想将此枚举添加到程序中:
enum AuthStatus {
NOT_DETERMINED,
NOT_LOGGED_IN,
LOGGED_IN,
}
if (user != null) {
_userId = user?.uid;
}
authStatus =
user?.uid == null ? AuthStatus.NOT_LOGGED_IN : AuthStatus.LOGGED_IN;
This way I could make a proper loading screen.这样我就可以制作一个正确的加载屏幕。 My question is where should I put this code and how?我的问题是我应该把这段代码放在哪里以及如何?
Treat them as values, for example例如,将它们视为值
AuthStatus _authStatus = NOT_DETERMINED;
if(_authStatus == NOT_DETERMINED){
tryLogin();
}
tryLogin(){
//login
_authStatus = LOGGED_IN;
}
just declare them outside any class on global level只需在全球范围内的任何 class 之外声明它们
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.