refactoring

This commit is contained in:
Mohamed Nouffer
2022-07-30 20:42:44 +05:30
parent a4adf24e99
commit 244b7eb9ac
14 changed files with 605 additions and 481 deletions

View File

@ -1,35 +1,35 @@
import 'package:geojson/geojson.dart';
import 'package:http/http.dart' as http;
import '../utils/const.dart';
class LocationLineService{
static Future<GeoJsonFeature?> loadLocationLines() async {
final geo = GeoJson();
GeoJsonFeature? fs;
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/location_line/';
//String url = 'http://localhost:8100/api/location_line/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
// static Future<GeoJsonFeature?> loadLocationLines() async {
// final geo = GeoJson();
// GeoJsonFeature? fs;
// String server_url = ConstValues.currentServer();
// String url = '${server_url}/api/location_line/';
// //String url = 'http://localhost:8100/api/location_line/';
// final response = await http.get(Uri.parse(url),
// headers: <String, String>{
// 'Content-Type': 'application/json; charset=UTF-8',
// },
// );
if (response.statusCode == 200) {
// if (response.statusCode == 200) {
geo.processedFeatures.listen((fst) {
fs = fst;
});
// geo.processedFeatures.listen((fst) {
// fs = fst;
// });
await geo.parse(response.body, verbose:true);
// await geo.parse(response.body, verbose:true);
return fs;
// return fs;
} else {
throw Exception('Failed to create album.');
}
}
// } else {
// throw Exception('Failed to create album.');
// }
// }
}