错误:由于返回类型“Never”,因此必须返回非空值。不允许为空
我使用 firebase 在我的 flutter 应用程序中编写了一个通过 google 登录的函数。但是当我尝试运行我的应用程序时,出现以下错误。我当前正在运行 flutter v2.5.3,但我将其升级到 v10...但它仍然不起作用
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:14:11: Error: Method not found: 'Error.throwWithStackTrace'.
Error.throwWithStackTrace(exception, stackTrace);
^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-
cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-
6.2.0/lib/src/method_channel/utils/exception.dart:17:9: Error: Method not found:
'Error.throwWithStackTrace'.
Error.throwWithStackTrace(
^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-
cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-
6.2.0/lib/src/method_channel/utils/exception.dart:12:7: Error: A non-null value must be
returned since the return type 'Never' doesn't allow null.
Never convertPlatformException(Object exception, StackTrace stackTrace) {
^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\flutter\bin\flutter.bat'' finished with non-zero exit
value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
Exception: Gradle task assembleDebug failed with exit code 1
下面是我的函数文件
class GoogleSignInProvider extends ChangeNotifier{
final googleSignIn=GoogleSignIn();
GoogleSignInAccount?_user;
GoogleSignInAccount? get user=>_user!;
Future googleLogin() async{
final googleUser=await googleSignIn.signIn();
if(googleUser != null) return _user=googleUser;
final googleAuth = await googleUser!.authentication;
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
await FirebaseAuth.instance.signInWithCredential(credential);
notifyListeners();
}
}
请帮助!
I wrote a function to login through google in my flutter app using firebase . But when I try to run my app I get the below error.I'm currently running flutter v2.5.3 but I upgraded it to v10... but still it didnt work
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:14:11: Error: Method not found: 'Error.throwWithStackTrace'.
Error.throwWithStackTrace(exception, stackTrace);
^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-
cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-
6.2.0/lib/src/method_channel/utils/exception.dart:17:9: Error: Method not found:
'Error.throwWithStackTrace'.
Error.throwWithStackTrace(
^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/.pub-
cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-
6.2.0/lib/src/method_channel/utils/exception.dart:12:7: Error: A non-null value must be
returned since the return type 'Never' doesn't allow null.
Never convertPlatformException(Object exception, StackTrace stackTrace) {
^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\flutter\bin\flutter.bat'' finished with non-zero exit
value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
Exception: Gradle task assembleDebug failed with exit code 1
Below is my function file
class GoogleSignInProvider extends ChangeNotifier{
final googleSignIn=GoogleSignIn();
GoogleSignInAccount?_user;
GoogleSignInAccount? get user=>_user!;
Future googleLogin() async{
final googleUser=await googleSignIn.signIn();
if(googleUser != null) return _user=googleUser;
final googleAuth = await googleUser!.authentication;
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
await FirebaseAuth.instance.signInWithCredential(credential);
notifyListeners();
}
}
Please help!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将Flutter版本升级到2.10.3。错误将消失。
Try upgrading flutter version to 2.10.3. The Error will be gone.