railway_chopper 0.2.0
railway_chopper: ^0.2.0 copied to clipboard
A chopper client factory and a Response -> Either<NetworkFailure, T> mapper for railway-oriented error handling in Flutter/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();
}