second commit
This commit is contained in:
44
lib/Data/Provider/CreatOrder/CreateOrderProvider.dart
Normal file
44
lib/Data/Provider/CreatOrder/CreateOrderProvider.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Request/Createorder/Createorderrequest.dart';
|
||||
import '../../../Model/Response/Createorder/CreateOrderResponsemodel.dart';
|
||||
|
||||
class CreateOrderProviders{
|
||||
Future<CreateOrderResponse?> createOrder(CreateOrder data,String urldata,) async {
|
||||
CreateOrderResponse? createOrder;
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
print('CreateOrderresponsebody ${response.body}');
|
||||
print('CreateOrderdatatoJson ${data.toJson()}');
|
||||
print('pickuplocationid ${data.pickup?.customerid}');
|
||||
print('droplocationid ${data.drop?.customerid}');
|
||||
logger.i(json.encode(data.toJson()));
|
||||
|
||||
// print('headerssssssssss ${response.headers}');
|
||||
print('CreateOrderurlsssssssssss ${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
createOrder = CreateOrderResponse.fromJson(parsedJson);
|
||||
print('createOrderinprovider${createOrder}');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return createOrder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user