
Replaces print statements with debugPrint across the application to prevent logging in release builds. Removes unused imports and variables for minor code cleanup.
30 lines
791 B
Dart
30 lines
791 B
Dart
import 'package:dio/dio.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
class ApiCalls {
|
|
static Future<Map<String, dynamic>?> fetchProduct(String barcode) async {
|
|
final Dio dio = Dio(
|
|
BaseOptions(baseUrl: 'https://world.openfoodfacts.org'),
|
|
);
|
|
try {
|
|
final response = await dio.get('/api/v0/product/$barcode.json');
|
|
|
|
if (response.statusCode == 200) {
|
|
final data = response.data;
|
|
if (data['status'] == 1) {
|
|
return data['product'];
|
|
} else {
|
|
debugPrint('Produit non trouvé');
|
|
return null;
|
|
}
|
|
} else {
|
|
debugPrint('Erreur réseau: ${response.statusCode}');
|
|
return null;
|
|
}
|
|
} catch (e) {
|
|
debugPrint('Erreur lors de la requête: $e');
|
|
return null;
|
|
}
|
|
}
|
|
}
|