updateByKey method

  1. @override
BlocxTestFormEntity updateByKey(
  1. BlocxTestFormField key,
  2. dynamic value
)
override

Updates the field identified by key and returns a new instance.

Implement using an immutable update pattern such as copyWith:

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

Implementation

@override
BlocxTestFormEntity updateByKey(BlocxTestFormField key, dynamic value) =>
    switch (key) {
      BlocxTestFormField.field1 => copyWith(field1: value as String? ?? ''),
      BlocxTestFormField.field2 => copyWith(field2: value as String? ?? ''),
    };