lazy method
Creates a Flutter effect hook that does not run automatically upon creation.
This method is a convenience constructor for creating a Flutter effect
with lazy set to true. The effect will not execute until you call
run. After the first manual run, it will track dependencies and re-run
at frame end whenever its reactive dependencies change.
Parameters:
effect: The effect function to executedebug: Optional debug options
Returns: A FlutterEffect that starts in deferred mode
Example:
setup(context, props) {
final count = useSignal(10);
final effect = useFlutterEffect.lazy(() {
print('Count is: ${count.value}');
});
onMounted(effect.run);
return () => Text('Count: ${count.value}');
}
Implementation
@defineHook
FlutterEffect lazy(void Function() effect, {JoltDebugOption? debug}) {
return useHook(_UseFlutterEffectHook(effect, true, debug));
}