useMemoized<T> function

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

Cache the instance of a complex object.

useMemoized will immediatly 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 <dynamic>[]]) {
  return Hook.use(_MemoizedHook(
    valueBuilder,
    keys: keys,
  ));
}