fake_store_api_client 1.0.2 copy "fake_store_api_client: ^1.0.2" to clipboard
fake_store_api_client: ^1.0.2 copied to clipboard

Cliente Flutter para la Fake Store API con Clean Architecture y manejo funcional de errores.

Fake Store API Client #

License: MIT Dart Flutter Platforms

Cliente Flutter para Fake Store API con manejo funcional de errores.

Instalación #

dependencies:
  fake_store_api_client: ^1.0.2

O ejecuta:

flutter pub add fake_store_api_client

Uso #

import 'package:fake_store_api_client/fake_store_api_client.dart';

final repository = FakeStoreApi.createRepository();

final result = await repository.getAllProducts();

result.fold(
  (failure) => print('Error: ${failure.message}'),
  (products) => print('${products.length} productos'),
);

API #

Método Retorno
getAllProducts() Either<Failure, List<Product>>
getProductById(id) Either<Failure, Product>
getAllCategories() Either<Failure, List<String>>
getProductsByCategory(cat) Either<Failure, List<Product>>

Manejo de Errores #

switch (result) {
  case Left(value: ConnectionFailure()): // Sin conexión
  case Left(value: ServerFailure()):     // Error 5xx
  case Left(value: NotFoundFailure()):   // Error 404
  case Left(value: InvalidRequestFailure()): // Error 4xx
  case Right(value: final data):         // Éxito
}

Ejemplo #

cd example && flutter run

Licencia #

MIT

0
likes
160
points
174
downloads

Publisher

unverified uploader

Weekly Downloads

Cliente Flutter para la Fake Store API con Clean Architecture y manejo funcional de errores.

Repository (GitHub)
View/report issues

Topics

#api-client #http #rest-api #clean-architecture

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on fake_store_api_client