railway_chopper 0.1.0 copy "railway_chopper: ^0.1.0" to clipboard
railway_chopper: ^0.1.0 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 mapResponse(
    () => client.get<Map<String, dynamic>, Map<String, dynamic>>(
      Uri.parse('/todos/1'),
    ),
  );

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

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

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

License

unknown (license)

Dependencies

chopper, fpdart, freezed_annotation, http

More

Packages that depend on railway_chopper