import 'package:cheminova/controller/home_service.dart';
import 'package:cheminova/models/user_model.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';

class HomeController extends GetxController {
  final HomeService homeService = HomeService();

  var user = Rxn<UserModel>();

  @override
  void onInit() {
    getUser();
    super.onInit();
  }

  Future<void> getUser() async
  {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    String? token = prefs.getString('token');
 user.value = (await homeService.getUser(token: token)) as UserModel? ;
  }
}
