Skip to content

Instantly share code, notes, and snippets.

@pawelsa
Last active March 2, 2022 20:02
Show Gist options
  • Save pawelsa/18efc57b6509a44910a21eda9f127168 to your computer and use it in GitHub Desktop.
Save pawelsa/18efc57b6509a44910a21eda9f127168 to your computer and use it in GitHub Desktop.
abstract class Response {}
abstract class SuccessfulResponse extends Response {}
abstract class ErrorResponse extends Response {}
abstract class Api {
Future<Response> get(Uri uri, Response Function(String body) mapper) {
return http.get(uri).then((value) => mapper(value.body));
}
// HTTP Post, Put, Delete and others can also be added here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment