繁体   English   中英

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

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

我在我的 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

下面是我的 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();
     }
    }

请帮忙!!!

尝试将 flutter 版本升级到 2.10.3。 错误将消失。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM