value property

  1. @override
Map<K, V?> value
override

The current value stored in this notifier.

When the value is replaced with something that is not equal to the old value as evaluated by the equality operator ==, this class notifies its listeners.

Implementation

@override
Map<K, V?> get value {
  final result = <K, V?>{};

  for (final pair in itemControllers) {
    final key = pair.keyController.value;

    if (key == null) {
      continue;
    }

    result[key] = pair.valueController.value;
  }

  return result;
}
  1. @override
void value=(Map<K, V?> values)
override

The list of current values that this controller holds.

When you set its value, the controller for each value is created. It allows for less than minLength items so the user can enter some initial info.

When you read its value, all controllers are surveyed for current values and the list of resulting values is returned.

Implementation

@override
set value(Map<K, V?> values) {
  if (values.length > maxLength) {
    throw Exception(
      'maxLength is $maxLength, got a list of ${values.length}.',
    );
  }

  final controllers = <MapEntryController<K, V, KC, VC>>[];

  for (final entry in values.entries) {
    controllers.add(_createController(entry.key, entry.value));
  }

  replaceControllers(controllers);
  notifyListeners();
}