When I run the code and there is error (I am testing catchError part), I get:
"Exception: Uncaught Error: type '_XMLHttpRequestProgressEvent' is not a subtype of type 'Error' of 'error'."
Because the type of parameter is not "Error" but "_XMLHttpRequestProgressEvent".
The type "Error" should be removed from the example.
And also print(error.toString()); outputs as "Instance of '_XMLHttpRequestProgressEvent'"
Better would be to have there for example: print(error.target.responseText);
In the API docs for HttpRequest (https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:html.HttpRequest) is example and it has catchError part with parameter type "Error".
When I run the code and there is error (I am testing catchError part), I get: "Exception: Uncaught Error: type '_XMLHttpRequestProgressEvent' is not a subtype of type 'Error' of 'error'."
Because the type of parameter is not "Error" but "_XMLHttpRequestProgressEvent". The type "Error" should be removed from the example.
And also print(error.toString()); outputs as "Instance of '_XMLHttpRequestProgressEvent'" Better would be to have there for example: print(error.target.responseText);