jolt_flutter 3.0.0 copy "jolt_flutter: ^3.0.0" to clipboard
jolt_flutter: ^3.0.0 copied to clipboard

Flutter library for jolt reactive signals library that builds reactive widgets from signals, automatically updating UI when signals change.

Jolt Flutter #

CI/CD codecov jolt_flutter License: MIT

Flutter integration for Jolt. Provides widgets like JoltBuilder and JoltSelector to use Jolt's reactive system in Flutter. Also includes bidirectional ValueNotifier conversion.

📦 Package Exports

jolt_flutter re-exports all APIs from the jolt package, so you only need to import jolt_flutter to access all Jolt reactive primitives (Signal, Computed, Effect, etc.).

Usage #

import 'package:jolt_flutter/jolt_flutter.dart';

final counter = Signal(0);

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

Core Widgets #

JoltBuilder #

Automatically rebuilds when any signal accessed in its builder changes:

final counter = Signal(0);
final name = Signal('Flutter');

JoltBuilder(
  builder: (context) => Column(
    children: [
      Text('Hello ${name.value}'),
      Text('Count: ${counter.value}'),
      ElevatedButton(
        onPressed: () => counter.value++,
        child: Text('Increment'),
      ),
    ],
  ),
)

JoltSelector #

Rebuilds only when a specific selector function's result changes:

final user = Signal(User(name: 'John', age: 30));

// Only rebuilds when the user's name changes, not age
JoltSelector(
  selector: (prev) => user.value.name,
  builder: (context, name) => Text('Hello $name'),
)

The selector function receives the previous selected value (or null on first run) and returns the new value to watch. Rebuilds occur only when the returned value changes.

ValueNotifier Integration #

Converting Jolt Signals to ValueNotifier #

Bridge Jolt signals with Flutter's ValueNotifier system using the extension:

final counter = Signal(0);
final notifier = counter.notifier; // Returns JoltValueNotifier

// Use with AnimatedBuilder
AnimatedBuilder(
  animation: notifier,
  builder: (context, child) => Text('Count: ${notifier.value}'),
)

// Use with ValueListenableBuilder
ValueListenableBuilder<int>(
  valueListenable: notifier,
  builder: (context, value, child) => Text('Count: $value'),
)

Converting ValueNotifier to Jolt Signal #

Convert Flutter's ValueNotifier to Jolt signals for bidirectional sync:

final notifier = ValueNotifier(0);
final signal = notifier.toNotifierSignal();

// Changes sync bidirectionally
notifier.value = 1; // signal.value becomes 1
signal.value = 2;   // notifier.value becomes 2

Automatic Synchronization #

ValueNotifier automatically syncs with Jolt signal changes:

final signal = Signal(0);
final notifier = signal.notifier;

// Changes to signal automatically update notifier
signal.value = 42; // notifier.value is now 42

Jolt Flutter is part of the Jolt ecosystem. Explore these related packages:

Package Description
jolt Core library providing Signals, Computed, Effects, and reactive collections
jolt_setup Setup Widget API and Flutter hooks: SetupWidget, SetupMixin, useTextEditingController, useScrollController, etc.
jolt_hooks Hooks API: useSignal, useComputed, useJoltEffect, useJoltWidget
jolt_surge Signal-powered Cubit pattern: Surge, SurgeProvider, SurgeConsumer
jolt_lint Custom lint and code assists: Wrap widgets, convert to/from Signals, Hook conversions

License #

This project is licensed under the MIT License - see the LICENSE file for details.

2
likes
160
points
543
downloads

Publisher

verified publishervowdemon.com

Weekly Downloads

Flutter library for jolt reactive signals library that builds reactive widgets from signals, automatically updating UI when signals change.

Homepage
Repository (GitHub)
View/report issues

Topics

#jolt #state-management #signals #flutter

Documentation

API reference

License

MIT (license)

Dependencies

flutter, jolt, meta, shared_interfaces

More

Packages that depend on jolt_flutter