service_client 0.2.0 copy "service_client: ^0.2.0" to clipboard
service_client: ^0.2.0 copied to clipboard

A service client abstraction for Dart with the Result pattern. Includes an HTTP implementation.

example/example.dart

import 'package:service_client/service_client.dart';

import 'controllers/todo_controller.dart';

/// View layer — delegates to the controller, renders based on Result.
void main() async {
  final controller = TodoController();

  print('Fetching ToDo #1 from JSONPlaceholder...\n');
  final result = await controller.fetchTodo(1);

  // Pattern matching forces handling of both cases at compile-time
  switch (result) {
    case Success(:final value):
      print('  ID:        ${value.id}');
      print('  Title:     ${value.title}');
      print('  Completed: ${value.isCompleted}');
    case Failure(:final error):
      print('Error ${error.statusCode}: ${error.message}');
  }
}
0
likes
160
points
140
downloads

Documentation

API reference

Publisher

verified publisherccisne.dev

Weekly Downloads

A service client abstraction for Dart with the Result pattern. Includes an HTTP implementation.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

http

More

Packages that depend on service_client