ModelType<M extends ModelType<M, V>, V> class

An abstract base class that defines common model attributes and behaviors.

Any class that extends this must be immutable and will have equality based on its current value, as provided by Equatable.

This class should not be extended, rather extend ModelValue.

Inheritance
Implementers
Annotations

Constructors

ModelType.fromPrevious(M previous)
A copy constructor.
ModelType.initial(V initialValue, ModelValueValidator<V> validator)
Constructor for the first instance of this ModelType.

Properties

hashCode int
The hash code for this object.
read-onlyinherited
initial → M
The initial instance of this model.
read-only
isInitial bool
True if this instance is the initial instance.
@nonVirtualread-only
modelType Type
@nonVirtualread-only
props List<Object>
The list of properties that will be used to determine whether two instances are equal.
read-onlyoverride
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
stringify bool
If set to true, the toString method will be overridden to output this instance's props.
read-onlyinherited
value → V
The current model value.
read-only
valueType Type
@nonVirtualread-only

Methods

asSerializable() → dynamic
Returns the current value of this model converted into a value serialisable using an encoding method such as JSON.encode.
buildFromModel(M nextModel) → M
Returns an instance of this model based on nextModel.
buildNext(V nextValue) → M
Returns a new instance of this model given nextValue.
deserialize(dynamic serialized) → V
Return serialized converted to the value type V of this model. Returns null if serialized could not be converted.
hasEqualityOfHistory(ModelType<ModelType, dynamic> other) bool
Determines whether other shares a history with this model.
next(V nextValue) → M
Returns a new instance whose value is set to nextValue, if nextValue is valid.
nextFromModel(ModelType<ModelType, dynamic> other) → M
Returns an instance of this model from other if (and only if) hasEqualityOfHistory is true after calling it on other.
nextWithDynamic(dynamic nextValue) → M
Calls next with nextValue after checking it is the value type V of this model.
nextWithFunc(ModelValueUpdater updater) → M
Calls nextWithDynamic after applying updater to the current model value.
nextWithSerialized(dynamic serialized) → M
Calls next with serialized after applying deserialize to it.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
shouldBuild(V nextValue) bool
Determines whether the model should build on nextValue.
toString() String
Debug toString method including the modelType and model value.
override
validate(V toValidate) bool
Determines whether toValidate is valid or not.

Operators

operator ==(Object other) bool
The equality operator.
inherited