LogoSignals.dart
Copy Markdown
rodydavis/signals.dart 999999

Type: SignalWidget

API reference and details for SignalWidget from signals.dart.

SignalWidget#

Kind: class  |  Package: package:signals_flutter

Class: SignalWidget#

A reactive StatelessWidget that implicitly tracks and rebuilds on signal changes.

SignalWidget establishes a dynamic reactive context directly at the Flutter element layer. Any signal accessed via .value inside the build method is implicitly tracked and subscribed to. When any of these signals mutate, only this widget is rebuilt.

This offers a clean, Javascript-style reactivity experience without needing manual builder widgets (like SignalBuilder) or deprecated context watch extensions.

Implicit Reactivity Example (Stateless)#

final username = signal('Rody');
final status = signal('Online');

class UserProfileView extends SignalWidget {
  const UserProfileView({super.key});

  @override
  Widget build(BuildContext context) {
    // 'username' and 'status' are implicitly tracked on access:
    return Column(
      children: [
        Text('Name: ${username.value}'),
        Text('Status: ${status.value}'),
      ],
    );
  }
}

Important

Only signals accessed synchronously during the execution of the build method are tracked. Signals read inside async callbacks, listeners, or deferred tasks are not subscribed to.

Members of SignalWidget#

Member Type Signature Description
SignalWidget constructor dart SignalWidget({super.key}) Constructor for SignalWidget.
createElement method dart StatelessElement createElement()

References#

The SignalWidget type is referenced and used in the following pages: