eventsubscriber 1.1.1 copy "eventsubscriber: ^1.1.1" to clipboard
eventsubscriber: ^1.1.1 copied to clipboard

outdated

A Flutter widget that updates (rebuilds) when an Event occurs.

EventSubscriber #

Pub Package

A Flutter widget that supports subscribing to an Event.

The EventSubscriber widget will be notified and rebuilt when the Event occurs, allowing some changing aspect of an observed object to be displayed in your Flutter user interface.

See also #

Event - broadcasts events to interested subscribers.

Dependencies #

  • Flutter - This Dart package has a dependency on the Flutter framework.
  • Event - Supports the creation of lightweight custom Dart Events, that allow interested subscribers to be notified that something has happened. Provides a notification mechanism across independent packages/layers/modules.

Usage #

A simple example:

import 'package:flutter/material.dart';
import 'package:event/event.dart';
import 'package:eventsubscriber/eventsubscriber.dart';

// An example domain model of a simple Counter
// Normally in its own module/package
// Included here inline for illustration purposes
class Count {
  int value = 0;
  var onValueChanged = Event(); // declare Event

  void increment() {
    value++;
    // Broadcast that the value has changed
    onValueChanged.broadcast();
  }
}

//////////////////////

// Create the domain model
var myCount = Count();

// Flutter application
// The Count domain value will increment when the button is pressed.
// The updated domain value will be automatically updated in the UI.
void main() => runApp(
      MaterialApp(
        home: Column(
          children: <Widget>[
            // Subscribe to the 'valueChanged' domain event
            EventSubscriber(
              event: myCount.onValueChanged,
              builder: (context) => Text(myCount.value.toString()),
            ),
            FlatButton(
              child: Text('Increment'),
              // Increment the domain value
              onPressed: () => myCount.increment(),
            )
          ],
        ),
      ),
    );

Features and bugs #

Please file feature requests and bugs at the issue tracker.

5
likes
0
pub points
73%
popularity

Publisher

verified publisheraryehoffman.com

A Flutter widget that updates (rebuilds) when an Event occurs.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

event, flutter

More

Packages that depend on eventsubscriber