flutter 版本升级到 flutter 2 后,我的 flutter 应用程序构建失败
/Users/sulfy/Developer/flutter/bin/flutter --no-color pub get 在 myflutterapp 中运行“flutter pub get”...
Because firebase_auth >=1.0.1 depends on firebase_auth_web ^1.0.1 which depends on http_parser ^4.0.0, firebase_auth >=1.0.1 requires http_parser ^4.0.0.
And because dio 3.0.10 depends on http_parser >=0.0.1 <4.0.0 and no versions of dio match >3.0.10 <4.0.0, firebase_auth >=1.0.1 is incompatible with dio ^3.0.10.
So, because myflutterapp depends on both dio ^3.0.10 and firebase_auth ^1.0.1, version solving failed.
pub get failed (1; So, because myflutterapp depends on both dio ^3.0.10 and firebase_auth ^1.0.1, version solving failed.)
Process finished with exit code 1
请建议我修复,我应该删除 dio 吗?或者是否有解决方法来解决这个问题?
在我将 firebase_auth 更新到最新版本后出现上述错误,因为我的带有电话号码身份验证的登录表单显示错误如下
Undefined class 'AuthCredential'. Try changing the name to the name of an existing class, or creating a class with the name 'AuthCredential'.
我的手机验证码如下
FirebaseAuth _auth = FirebaseAuth.instance;
_auth.verifyPhoneNumber(
phoneNumber: phone,
timeout: Duration(seconds: 60),
verificationCompleted: (AuthCredential credential) async {
//error: Undefined class 'AuthCredential'.
Navigator.of(context).pop();
UserCredential result = await _auth
.signInWithCredential(credential)
//error: The method 'signInWithCredential' isn't defined for the type 'FirebaseAuth'.
.then((value) => null)
.catchError((e) {
// print('User Exist');
});
//error: Undefined class 'UserCredential'.
User user = result.user;
//error: Undefined class 'User'.
if (user != null) {
//redirect user
} else {
// print("Error");
}
},
verificationFailed: (FirebaseAuthException exception) {
},
codeSent: (String verificationId, [int forceResendingToken]) { },
codeAutoRetrievalTimeout: (String verificationId) {
//
});
答案 0 :(得分:0)
如果您的 pubspec.yaml 中有指定版本的 http_parser,您可以尝试删除此行,然后运行 flutter pub get。
如果上面没有解决问题,可以试试这个: https://dart.dev/tools/pub/dependencies#dependency-overrides