43 lines
1.1 KiB
Dart
43 lines
1.1 KiB
Dart
import 'package:get/get.dart';
|
|
import '../models/econtrol_model.dart';
|
|
import '../services/geolocation_service.dart';
|
|
import '../services/econtrol_service.dart';
|
|
|
|
class GasstationsController extends GetxController {
|
|
final isLoading = false.obs;
|
|
final isLoadingLocation = false.obs;
|
|
final eControlData = <EControlModel>[].obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
_loadStationInfosList();
|
|
super.onInit();
|
|
}
|
|
|
|
@override
|
|
void onReady() {}
|
|
|
|
@override
|
|
void onClose() {}
|
|
|
|
Future<void> _loadStationInfosList() async {
|
|
isLoading.value = true;
|
|
var gelocationService = GeolocationService();
|
|
var eControlService = EControlService();
|
|
// check if location is available
|
|
await gelocationService.getCurrentLocation();
|
|
if (gelocationService.hasLocation) {
|
|
var listResult = await eControlService.getEControlData(
|
|
gelocationService.latitude,
|
|
gelocationService.longitude,
|
|
'DIE',
|
|
);
|
|
eControlData.value = listResult
|
|
.map((json) => EControlModel.fromJson(json))
|
|
.toList();
|
|
}
|
|
isLoading.value = false;
|
|
update();
|
|
}
|
|
}
|