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

Simple Event Notifier

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:simple_event_notifier/simple_event_notifier.dart';

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

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

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

class MyAppState extends State<MyApp> {
  late StreamSubscription<String> subscription;

  @override
  void initState() {
    subscription = EventNotifier.receive('button_pressed', eventTriggerCallback);
  }

  @override
  void dispose() {
    subscription.cancel();
    super.dispose();
  }

  void eventTriggerCallback(){
    print("eventTriggerCallback");
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Event Notifier Example'),
        ),
        body: Center(
          child: TextButton(
            onPressed: () {
              EventNotifier.notify('button_pressed');
            },
            child: Text('Press me'),
          ),
        ),
      ),
    );
  }
}
2
likes
140
points
17
downloads

Publisher

verified publisherabrovinc.com

Weekly Downloads

Simple Event Notifier

Repository (GitHub)
View/report issues

Documentation

API reference

License

LGPL-3.0 (license)

Dependencies

flutter

More

Packages that depend on simple_event_notifier