BlocxBaseFormEntity<F extends BlocxBaseFormEntity<F, E>, E extends Enum> class abstract

Base class for all immutable form entities used by BlocxFormBloc.

Enforces a consistent enum-keyed update/read contract so the form system can handle field updates, validation, and UI refresh generically — without knowing the concrete field types at compile time.

Type parameters

  • F: The concrete subclass (F-bound polymorphism). Ensures updateByKey returns a strongly-typed instance rather than the base class.
  • E: The enum whose values map 1-to-1 to form fields.

Required overrides

Only updateByKey is required. Implement it as an immutable field swap, typically delegating to copyWith:

@override
LoginForm updateByKey(LoginField key, dynamic value) => switch (key) {
  LoginField.email    => copyWith(email: value),
  LoginField.password => copyWith(password: value),
};

Optional overrides

Override getValueByKey when the form system needs to read field values back — e.g. for the debug-mode consistency check in updateByKeySafe, or for validation that inspects other fields:

@override
dynamic getValueByKey(LoginField key) => switch (key) {
  LoginField.email    => email,
  LoginField.password => password,
};

Override getFormattedValueByKey only when a field has a display representation that differs from its stored value (e.g. a date formatted as a locale string).

Equality

Equality is inherited from BlocxBaseEntity and is based solely on identifier. Two form entity instances with the same identifier are considered equal regardless of field values.

Inheritance

Constructors

BlocxBaseFormEntity()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
identifier String
A globally unique and constant identifier for the entity.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getFormattedValueByKey(E key) → dynamic
Returns a formatted display value for key.
getFormattedValueIfNotNullOtherwiseValue(E key) → dynamic
Returns getFormattedValueByKey if non-null, otherwise getValueByKey.
getValueByKey(E key) → dynamic
Returns the stored value for key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
updateByKey(E key, dynamic value) → F
Updates the field identified by key and returns a new instance.
updateByKeySafe(E key, dynamic value) → F
Calls updateByKey and validates the result in debug mode.

Operators

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