re factor rog

This commit is contained in:
2024-04-01 09:26:56 +05:30
parent dd36ab8399
commit edbf52825b
54 changed files with 2597 additions and 435 deletions

View File

@ -0,0 +1,27 @@
import 'package:dio/dio.dart';
import 'package:rogapp/features/data/checkpoint.dart';
class ApiService {
final Dio _dio = Dio();
Future<FeatureCollection> fetchFeatures() async {
try {
final tmp_url =
"https://rogaining.sumasen.net/api/inbound?rog=True&grp=養老ロゲ&ln1=136.52675654298724&la1=35.19710769333327&ln2=136.52675654298724&la2=35.38264844179004&ln3=136.65061968584442&la3=35.38264844179004&ln4=136.65061968584442&la4=35.19710769333327";
final response = await _dio.get(tmp_url);
if (response.statusCode == 200) {
return FeatureCollection.fromJson(response.data);
} else {
throw Exception('Failed to load features');
}
} on DioException catch (e) {
// Handle Dio errors here
print('Dio error: $e');
throw Exception('Failed to load features');
} catch (e) {
// Handle any other errors
print('General error: $e');
throw Exception('Failed to load features');
}
}
}