fetchWebPrediction method
- AppLocalizations localizations
Fetches a prediction from the web-based classification service.
This is typically used as a fallback when local classification results in low confidence or unknown species.
Parameters:
- localizations: Used for localized error messages
Updates:
- _isFetchingWebPrediction: Tracks the web request state
- _webPredictionResult: Contains the web prediction results
- _errorMessage: Contains error details if the request fails
Implementation
Future<void> fetchWebPrediction(AppLocalizations localizations) async {
if (_imageFile == null) return;
_isFetchingWebPrediction = true;
_webPredictionResult = null;
_errorMessage = null;
notifyListeners();
try {
final result = await _repository.getWebPrediction(_imageFile!);
_webPredictionResult = result;
} catch (e) {
print("!!! ERROR fetching web prediction: $e");
_errorMessage = localizations.errorFailedWebPrediction; // Add this to your ARB files
} finally {
_isFetchingWebPrediction = false;
notifyListeners();
}
}