recreate method

T recreate(
  1. T? current
)

Recreates the value if necessary. Current keys are compared against new Keys.

Implementation

T recreate(T? current) {
  List<Object?>? updatedKeys = widget.keys?.call(context) ?? [];
  bool hasChanged = !iterablesAreEqual(keys, updatedKeys);
  if (hasChanged) {
    if (current != null) {
      widget.dispose?.call(context, current);
    }
    current = widget.create(context);
    keys = updatedKeys;
  }
  return current as T;
}