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

outdated

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

example/lib/main.dart

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

import 'counter.dart';

// Create the domain model
var myCounter = 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(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.purple,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text("EventSubscriber Example"),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              //=================================
              // Subscribe to the 'valueChangedEvent' domain event
              // The handler will be run whenever the Event occurs
              EventSubscriber(
                event: myCounter.valueChangedEvent,
                builder: (context, args) => Text(
                  myCounter.value.toString(),
                  style: Theme.of(context).textTheme.headline3,
                ),
              ),
              //=================================
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: myCounter.increment,
          tooltip: 'Increment',
          child: const Icon(Icons.add),
        ),
      ),
    );
  }
}
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