Files
rog_app/lib/services/reacking_service.dart
Mohamed Nouffer 56e9861c7a update to 3.13
2023-09-03 23:37:41 +05:30

33 lines
869 B
Dart

import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:rogapp/utils/const.dart';
class TrackingService {
static Future<Map<String, dynamic>> addTrack(String userId, double lat, double lon) async {
Map<String, dynamic> cats = {};
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/track/';
print('++++++++$url');
final geom = '{"type": "MULTIPOINT", "coordinates": [[$lon, $lat]]}';
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'user_id': userId,
'geom': geom
}),
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
}