useCallback<T extends Function> function
Cache a function across rebuilds based on a list of keys.
This is syntax sugar for useMemoized, so that instead of:
final cachedFunction = useMemoized(() => () {
print('doSomething');
}, [key]);
we can directly do:
final cachedFunction = useCallback(() {
print('doSomething');
}, [key]);
Implementation
T useCallback<T extends Function>(
T callback, [
List<Object?> keys = const <Object>[],
]) {
return useMemoized(() => callback, keys);
}