railway_chopper 0.2.1 copy "railway_chopper: ^0.2.1" to clipboard
railway_chopper: ^0.2.1 copied to clipboard

A chopper client factory and a Response -> Either<NetworkFailure, T> mapper for railway-oriented error handling in Flutter/Dart.

example/main.dart

import 'package:railway_chopper/railway_chopper.dart';

Future<void> main() async {
  // Build a preconfigured client. In a real app, attach your generated
  // `@ChopperApi` services to it instead of calling `client.get` directly.
  final client = buildChopperClient(
    baseUrl: 'https://jsonplaceholder.typicode.com',
  );

  final result = await client
      .get<Map<String, dynamic>, Map<String, dynamic>>(Uri.parse('/todos/1'))
      .toEither();

  result.match(
    (failure) => print('Request failed: $failure'),
    (todo) => print('Todo #${todo['id']}: ${todo['title']}'),
  );

  client.dispose();
}
5
likes
160
points
236
downloads

Documentation

API reference

Publisher

verified publisherstucknot.com

Weekly Downloads

A chopper client factory and a Response -> Either<NetworkFailure, T> mapper for railway-oriented error handling in Flutter/Dart.

Repository (GitHub)
View/report issues

Topics

#network #http #chopper #either #error-handling

License

MIT (license)

Dependencies

chopper, fpdart, freezed_annotation, http

More

Packages that depend on railway_chopper