简体   繁体   English

ArgumentError(无效参数(onError):Future.catchError 的错误处理程序必须返回未来类型的值)

[英]ArgumentError (Invalid argument(s) (onError): The error handler of Future.catchError must return a value of the future's type)

ArgumentError (Invalid argument(s) (onError): The error handler of Future.catchError must return a value of the future's type) ArgumentError(无效参数(onError):Future.catchError 的错误处理程序必须返回未来类型的值)

final User? firebaseUser = (
        await fAuth.signInWithEmailAndPassword(
        email: emailTextEditingController.text.trim(),
        password: passwordTextEditingController.text.trim()
        ).catchError((msg){
        
        Navigator.pop(context);
        Fluttertoast.showToast(msg: "Error" +msg.toString());
        })
        
        ).user;

       
  

Create async method to fetch user.创建异步方法来获取用户。

User? firebaseUser() async {
  return await fAuth
      .signInWithEmailAndPassword(
          email: emailTextEditingController.text.trim(),
          password: passwordTextEditingController.text.trim())
      .user;
}

you can show toast based on null user.您可以根据 null 用户显示 toast。

checkError() async {
  final user = await firebaseUser();

  if(user==null){
    //show message
  }
}

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

相关问题 一种在 Future.catchError 上返回继承对象的方法 - A way to return inherited object on Future.catchError Future.then 必须返回返回的未来类型的值 - Future.then must return a value of the returned future's type Flutter Future Builder 中的无效参数 - Invalid argument(s) in Flutter Future Builder 在 Future 的 then 中返回 Future - Return Future within Future's then 可迭代 toList() 抛出 - ArgumentError(无效参数(输入):不能为空) - Iterable toList() throws - ArgumentError (Invalid argument(s) (input): Must not be null) dio http 获取错误 ArgumentError(无效参数(输入):不得为空)flutter - dio http get error ArgumentError (Invalid argument(s) (input): Must not be null) flutter http.dart onError 的无效参数:无效参数(onError):错误处理程序必须接受一个对象或一个对象和一个 StackTrace 作为参数 - http.dart invalid argument for onError: Invalid argument (onError): Error handler must accept one Object or one Object and a StackTrace as arguments 将来使用 catchError 捕获错误并抛出另一种类型 - Catch error using catchError in a future and throw another type 如何从catchError中的Future.error获取值? - How to get the value from Future.error inside catchError? 根据闭包上下文的要求,返回类型“Null”不是“Future&lt;_&gt;” - The return type 'Null' isn't a 'Future<_>', as required by the closure's context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM