eventpub 0.0.2 copy "eventpub: ^0.0.2" to clipboard
eventpub: ^0.0.2 copied to clipboard

A event manager library

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final eventpub = EventPub();

  @override
  void initState() {
    eventpub.dispatch("message", {"data": "Hola"});
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    eventpub.listen("message", (data) {
      print(data);
    });

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: const Center(
          child: Text('Hello'),
        ),
      ),
    );
  }
}