ClassificationViewModel class
A view model that manages the classification of mosquito images.
This class handles the entire classification workflow including:
- Image selection from device
- Local image classification
- Web-based prediction fallback
- Observation submission
- Inheritance
-
- Object
- ChangeNotifier
- ClassificationViewModel
Constructors
- ClassificationViewModel({required ClassificationRepository repository, required UserService userService})
Properties
- errorMessage → String?
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasImage → bool
-
no setter
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- imageFile → File?
-
no setter
- isFetchingWebPrediction → bool
-
no setter
- isProcessing → bool
-
no setter
- isSubmitting → bool
-
no setter
- modelId → String
-
final
- result → ClassificationResult?
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldShowDiseaseRiskButton → bool
-
Determines if the disease risk button should be shown.
no setter
- state → ClassificationState
-
no setter
- submissionResult → Observation?
-
no setter
- webPredictionResult → WebPredictionResult?
-
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
classifyImage(
AppLocalizations localizations) → Future< void> - Classifies the currently selected image using the local model.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
fetchWebPrediction(
AppLocalizations localizations) → Future< void> - Fetches a prediction from the web-based classification service.
-
initModel(
AppLocalizations localizations) → Future< void> - Initializes the classification model for local predictions.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
pickImage(
ImageSource source, AppLocalizations localizations) → Future< void> - Picks an image from the specified source for classification.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
reset(
) → void - Resets the view model to its initial state.
-
setErrorMessage(
String? message) → void - Sets an error message to be displayed to the user.
-
setImageFile(
File? file) → void - Sets the current image file and resets related state if needed.
-
setResult(
ClassificationResult? result) → void - Sets the classification result.
-
setState(
ClassificationState state) → void - Updates the current state of the view model.
-
submitObservation(
{required ClassificationResult localResult, required WebPredictionResult? webPrediction, required double latitude, required double longitude, required String notes, required AppLocalizations localizations}) → Future< Observation?> - Submits an observation to the server with classification results.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited