You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App_New/lib/features/authentication/authentication_view_model.dart

48 lines
1.5 KiB
Dart

import 'dart:developer';
import 'dart:io';
2 months ago
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/api_consts.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart';
import 'package:hmg_patient_app_new/features/authentication/models/check_activation_code_request_register.dart';
2 months ago
class AuthenticationViewModel extends ChangeNotifier {
AuthenticationRepo authenticationRepo;
AppState appState;
AuthenticationViewModel({
required this.appState,
required this.authenticationRepo,
});
final TextEditingController nationalIdController = TextEditingController();
final TextEditingController phoneNumberController = TextEditingController();
2 months ago
Future<void> selectDeviceImei({
Function(dynamic)? onSuccess,
Function(String)? onError
}) async {
final String firebaseToken =
2 months ago
"cIkkB7h7Q7uoFkC4Qv82xG:APA91bEb53Z9XzqymCIctaLxCoMX6bm9fuKlWILQ59uUqfwhCoD42AOP1-jWGB1WYd9BVN5PT2pUUFxrT07vcNg1KH9OH39mrPgCl0m21XVIgWrzNnCkufg";
final resultEither =
await authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken);
resultEither.fold(
(failure) {
notifyListeners();
if (onError != null) onError(failure.message);
},
(data) {
2 months ago
log("resultEither: ${data.toString()} ");
notifyListeners();
if (onSuccess != null) onSuccess(data);
},
);
}
}