error_handler 1.1.0 copy "error_handler: ^1.1.0" to clipboard
error_handler: ^1.1.0 copied to clipboard

error handler for all http client in dart like dio, chopper http and more

example/error_handler_example.dart

import 'package:dio/dio.dart';
import 'package:error_handler/error_handler.dart';

import 'post.dart';

FutureResponse<Post> getPost() async {
  final dio = Dio();

  final response =
      await dio.get("https://jsonplaceholder.typicode.com/posts/1");

  return response.convert(Post.fromJson);
}

Future<void> main() async {
  final state = await errorHandler.future(getPost);

  state.whenOrNull(
    data: (post, response) {
      print("title: ${post.title}");
    },
    error: (error) {
      print(getErrorMessage(error));
    },
  );
}
17
likes
130
pub points
52%
popularity

Publisher

verified publishermatheer.com

error handler for all http client in dart like dio, chopper http and more

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

chopper, dio, freezed_annotation

More

Packages that depend on error_handler