re factor rog
This commit is contained in:
27
lib/features/services/checkpoint_service.dart
Normal file
27
lib/features/services/checkpoint_service.dart
Normal 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');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user