second commit
This commit is contained in:
32
lib/Data/Provider/Orders/Ordersprovider.dart
Normal file
32
lib/Data/Provider/Orders/Ordersprovider.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'dart:convert';
|
||||
import 'package:NearleDailyBusiness/Helper/Logger.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../Model/Response/Orders/Getorderresponse.dart';
|
||||
|
||||
|
||||
class OrdersProvider {
|
||||
Future<GetOrders?> getOrders(String url) async {
|
||||
try {
|
||||
print('🌐 GetOrderUrl : $url');
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
print('📦 Response Status: ${response.statusCode}');
|
||||
print('📦 Response Body: ${response.body}');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = jsonDecode(response.body);
|
||||
|
||||
logger.i("GetOrders Response: ${jsonEncode(data)}");
|
||||
|
||||
return GetOrders.fromJson(data);
|
||||
} else {
|
||||
print('❌ Failed to load orders: ${response.reasonPhrase}');
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
print('🚨 Exception in getOrders: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user