Files
rog_app/lib/services/location_line_service.dart

33 lines
807 B
Dart
Raw Normal View History

2022-03-14 12:28:57 +05:30
import 'package:geojson/geojson.dart';
import 'package:http/http.dart' as http;
2022-06-14 14:37:59 +05:30
import '../utils/const.dart';
2023-10-06 16:25:21 +05:30
class LocationLineService {
static Future<GeoJsonFeature?> loadLocationLines() async {
2022-03-14 12:28:57 +05:30
final geo = GeoJson();
GeoJsonFeature? fs;
2023-08-16 14:53:32 +05:30
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/location_line/';
2023-10-06 16:25:21 +05:30
//print('++++++++$url');
final response = await http.get(
Uri.parse(url),
2022-03-14 12:28:57 +05:30
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
geo.processedFeatures.listen((fst) {
fs = fst;
});
2023-10-06 16:25:21 +05:30
await geo.parse(response.body, verbose: true);
2022-03-14 12:28:57 +05:30
return fs;
} else {
throw Exception('Failed to create album.');
}
}
2023-10-06 16:25:21 +05:30
}