The error handler of Future.catchError must return a value of the future's type

Viewed 26

I got this error message any help!! this code worked well recently

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

Unhandled exception:
Invalid argument(s) (onError): The error handler of Future.catchError must return a value of the future's type
void main() {
  getName().then((value) {
    print(value);
    throw ('Some arbitrary error');
  }).catchError((err) {
    print(err.toString());
  
  });
}

Future<String> getName() async {
  return "woo";
}



0 Answers
Related