jolt_hooks library

A Flutter hooks integration package for Jolt reactive state management.

Jolt Hooks provides a comprehensive Hooks API built on flutter_hooks, enabling you to use Jolt's reactive primitives seamlessly within Flutter's hook system. All hooks automatically dispose their resources when the widget is removed from the tree, ensuring memory safety and preventing leaks.

Documentation

Official Documentation

Quick Start

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:jolt_hooks/jolt_hooks.dart';

class CounterWidget extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final count = useSignal(0);
    final doubled = useComputed(() => count.value * 2);

    return Scaffold(
      body: HookBuilder(
        builder: (context) => useJoltWidget(() {
          return Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Count: ${count.value}'),
              Text('Doubled: ${doubled.value}'),
              ElevatedButton(
                onPressed: () => count.value++,
                child: Text('Increment'),
              ),
            ],
          );
        }),
      ),
    );
  }
}

Integration with JoltBuilder

You can also use JoltBuilder from jolt_flutter package for reactive UI updates:

import 'package:jolt_flutter/jolt_flutter.dart';

Widget build(BuildContext context) {
  final count = useSignal(0);

  return JoltBuilder(
    builder: (context) => Text('Count: ${count.value}'),
  );
}

Classes

JoltComputedHookCreator
Helper class for creating computed hooks.
JoltEffectHook<S extends EffectNode>
A Flutter hook that wraps Jolt effect nodes.
JoltEffectHookCreator
Helper class for creating effect hooks.
JoltEffectHookState<S extends EffectNode>
The state class for JoltEffectHook.
JoltEffectScopeHookCreator
Helper class for creating effect scope hooks.
JoltHook<T, S extends ReadableNode<T>>
A Flutter hook that wraps Jolt reactive values.
JoltHookState<T, S extends ReadableNode<T>>
The state class for JoltHook.
JoltSignalHookCreator
Helper class for creating signal hooks.
JoltWatcherHookCreator
Helper class for creating watcher hooks.
JoltWidgetHook<T extends Widget>
A Flutter hook that wraps Jolt reactive widget builders.
JoltWidgetHookState<T extends Widget>
The state class for JoltWidgetHook.

Constants

useComputed → const JoltComputedHookCreator
Creates a computed signal hook that derives its value from other signals.
useSignal → const JoltSignalHookCreator
Creates a reactive signal hook that holds a mutable value.

Properties

useEffectScope JoltEffectScopeHookCreator
Creates an effect scope hook for managing effect lifecycles.
final
useJoltEffect JoltEffectHookCreator
Creates a reactive effect hook that runs when dependencies change.
final
useWatcher JoltWatcherHookCreator
Creates a watcher hook that observes changes with fine-grained control.
final

Functions

useJoltStream<T>(Readable<T> value, {List<Object?>? keys}) Stream<T>
Creates a stream hook from a reactive value.
useJoltWidget<T extends Widget>(T builder(), {List<Object?>? keys}) → T
Creates a reactive widget hook that automatically rebuilds when dependencies change.