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.
		
		
		
		
		
			
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
import '../../locator.dart';
 | 
						|
import 'base_view_model.dart';
 | 
						|
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
 | 
						|
import 'package:diplomaticquarterapp/core/model/pharmacies/pharmacies_model.dart';
 | 
						|
import 'package:diplomaticquarterapp/core/service/pharmacies_service.dart';
 | 
						|
 | 
						|
class PharmacyViewModel extends BaseViewModel {
 | 
						|
  bool isFinished = true;
 | 
						|
  bool hasError = false;
 | 
						|
  String errorMsg = '';
 | 
						|
  PharmacyService _pharmacyService = locator<PharmacyService>();
 | 
						|
 | 
						|
  List<PharmaciesModel> get pharmacy => _pharmacyService.pharmaciesList;
 | 
						|
 | 
						|
  Future getMedicine() async {
 | 
						|
    setState(ViewState.Busy);
 | 
						|
    await _pharmacyService.getMedicine();
 | 
						|
    if (_pharmacyService.hasError) {
 | 
						|
      error = _pharmacyService.error;
 | 
						|
      setState(ViewState.Error);
 | 
						|
    } else
 | 
						|
      setState(ViewState.Idle);
 | 
						|
  }
 | 
						|
 | 
						|
  Future getMedicine2({String name}) async {
 | 
						|
    hasError = false;
 | 
						|
    _pharmacyService.clearPharmaciesLis();
 | 
						|
    setState(ViewState.BusyLocal);
 | 
						|
    await _pharmacyService.getMedicine(drugName: name);
 | 
						|
    if (_pharmacyService.hasError) {
 | 
						|
      error = _pharmacyService.error;
 | 
						|
      setState(ViewState.ErrorLocal);
 | 
						|
    } else
 | 
						|
      setState(ViewState.Idle);
 | 
						|
  }
 | 
						|
}
 |