简体   繁体   English

错误:必须返回非空值,因为返回类型“从不”不允许 null

[英]Error: A non-null value must be returned since the return type 'Never' doesn't allow null

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我在我的 flutter 应用程序中使用 firebase 编写了一个 function 以通过谷歌登录。但是当我尝试运行我的应用程序时出现以下错误。我目前正在运行 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

Below is my function file下面是我的 function 文件

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!!!请帮忙!!!

Try upgrading flutter version to 2.10.3.尝试将 flutter 版本升级到 2.10.3。 The Error will be gone.错误将消失。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter Firebase Auth 上的编译错误:“必须返回非空值,因为返回类型‘从不’不允许 null。” - Flutter Compile Error on Firebase Auth: "A non-null value must be returned since the return type 'Never' doesn't allow null." 错误:必须返回非空值,因为返回类型“Never”不允许 null。Never convertPlatformException(对象异常,StackTrace - Error: A non-null value must be returned since the return type 'Never' doesn't allow null. Never convertPlatformException(Object exception, StackTrace 必须返回非空值,因为返回类型“UserCredentialPlatform”不允许空值 - A non-null value must be returned since the return type 'UserCredentialPlatform' doesn't allow null FirebaseCloudMessaging: PlatformException (PlatformException(null-error, Host platform returned null value for non-null return value., null, null)) - FirebaseCloudMessaging : PlatformException (PlatformException(null-error, Host platform returned null value for non-null return value., null, null)) 未处理的异常:PlatformException(空错误,主机平台为非空返回值返回 null 值。,null,空) - Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null) 获取多个分区中的下一个(或上一个)非空值 - Get the next (or previous) non-null value in multiple partitioned 在 bigQuery 中仅返回非空键/值 - Returning only non-null key/value in bigQuery 正文可能会正常完成,导致返回“null”,但返回类型可能是不可为空的类型 - The body might complete normally, causing 'null' to be returned, but the return type, is a potentially non-nullable type 必须向 Text 小部件提供非空字符串。 断言失败:第 378 行 pos 10: 'data != null' - A non-null String must be provided to a Text widget. Failed assertion: line 378 pos 10: 'data != null' 主体可能正常完成,导致返回“null”,但返回类型“Widget”可能是不可为 null 的类型。 Flutter码 - The body might complete normally, causing 'null' to be returned, but the return type, 'Widget', is a potentially non-nullable type. Flutter code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM