useMemoized<T> function Null safety

T useMemoized<T>(
  1. T valueBuilder(
      ),
    1. [List<Object?> keys = const <Object>[]]
    )

    Cache the instance of a complex object.

    useMemoized will immediately call valueBuilder on first call and store its result. Later, when HookWidget rebuilds, the call to useMemoized will return the previously created instance without calling valueBuilder.

    A later call of useMemoized with different keys will call useMemoized again to create a new instance.

    Implementation

    T useMemoized<T>(
      T Function() valueBuilder, [
      List<Object?> keys = const <Object>[],
    ]) {
      return use(
        _MemoizedHook(
          valueBuilder,
          keys: keys,
        ),
      );
    }