MlValidator class abstract
Base class for ML-powered validators that run on-device TFLite models.
Subclasses implement preprocess and postprocess to define how input text becomes model input and how model output becomes a validation result.
class MyMLValidator extends MlValidator {
MyMLValidator() : super(
modelAsset: 'packages/formwise/models/my_model.tflite',
maxLength: 64,
);
@override
List<List<double>> preprocess(String input) { ... }
@override
MlValidationResult postprocess(List<dynamic> output, String input) { ... }
}
- Implementers
Constructors
- MlValidator({required String modelAsset, int maxLength = 64, String vocab = TextPreprocessor.defaultVocab, ModelLoader? loader})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isReady → bool
-
Whether the model has been loaded and is ready for inference.
no setter
- modelAsset → String
-
final
- preprocessor → TextPreprocessor
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asAsyncValidator(
{String? fallbackValidator(String?)?}) → Future< String?> Function(String?) - Creates a validator function compatible with SmartTextFormField.
-
dispose(
) → void - Releases the model resources.
-
initialize(
) → Future< void> - Loads the model. Must be called before validate.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
postprocess(
List rawOutput, String input) → MlValidationResult - Interprets model output into a validation result.
-
preprocess(
String input) → List< List< double> > - Converts input text into the model's expected input tensor format.
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
String input) → Future< MlValidationResult> -
Runs the model on
inputand returns a validation result.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited