Skip to content

Instantly share code, notes, and snippets.

@nicodoss
Created September 1, 2022 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicodoss/dfce1e1f8cfc565898cb1ff424cd23c9 to your computer and use it in GitHub Desktop.
Save nicodoss/dfce1e1f8cfc565898cb1ff424cd23c9 to your computer and use it in GitHub Desktop.
LivresServices
import 'dart:convert';
import 'package:dio/dio.dart';
import '../../Globales/BaseUrl.dart';
import '../modules/livres/models/livres.dart';
class LivreServices {
Future<List<Livres>>? getListLivresByAuteurs(List<String> idAuteurs) async {
List<Livres> lstLivres = [];
String appendString = "";
for (String p in idAuteurs) {
appendString = idAuteurs.join("&auteursIds=");
}
// String url=
try {
Dio dio = new Dio();
print('------------------Livres Service-----------');
print(BaseUrl.urlApi + "/booksByListAuteur/?auteursIds=$appendString");
final response = await dio
.get(BaseUrl.urlApi + "/booksByListAuteur/?auteursIds=$appendString");
final jsonresponse = jsonDecode(response.data);
for (var p in jsonresponse['object'] as List<Map<String, dynamic>>) {
lstLivres.add(Livres.fromJson(p['object']));
}
} catch (e) {
print("error");
print(e);
}
return lstLivres;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment