update
This commit is contained in:
46
lib/pages/destination/destination_controller.dart
Normal file
46
lib/pages/destination/destination_controller.dart
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/destination_service.dart';
|
||||
|
||||
class DestinationController extends GetxController {
|
||||
|
||||
|
||||
List<dynamic> destinations = <dynamic>[].obs;
|
||||
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
PopulateDestinations();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void PopulateDestinations(){
|
||||
if(indexController.currentUser.isNotEmpty){
|
||||
int user_id = indexController.currentUser[0]["user"]["id"] as int;
|
||||
//print(user_id);
|
||||
DestinationService.getDestinations(user_id).then((value){
|
||||
destinations.clear();
|
||||
destinations = value;
|
||||
//var val = value[2]["location"]["id"];
|
||||
//print("-----current destinations ----- ${val}");
|
||||
});
|
||||
}
|
||||
else{
|
||||
Get.toNamed(AppPages.LOGIN);
|
||||
}
|
||||
}
|
||||
|
||||
void makeOrder(BuildContext context, int action_id, int order, String dir){
|
||||
DestinationService.updateOrder(action_id, order, dir).then((value){
|
||||
//print("----action value----${value}");
|
||||
PopulateDestinations();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user