clean_api 0.0.4 clean_api: ^0.0.4 copied to clipboard
Cleanest way to implement Rest Api with caching using functional programming aproach.
Getting started #
First setup your base url
void main() {
CleanApi.instance().setBaseUrl('https://baseurl.com/');
runApp(const MyApp());
}
Fetch your data #
final Either<ApiFailure, CatModel> response = await cleanApi.get(
fromJson: (json) => CatModel.fromJson(json), endPoint: 'fact');
changeState = response.fold((l) => l.toString(), (r) => r.fact);