ui_event_bus 1.0.1 copy "ui_event_bus: ^1.0.1" to clipboard
ui_event_bus: ^1.0.1 copied to clipboard

A Flutter package offering a singleton broadcast event bus for easy global management of SnackBars, navigation, dialogs, and custom callbacks.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return UIGlobalEventBus(
      MaterialApp(
        home: const EventEx1(),
        scaffoldMessengerKey: eventScaffoldKey,
        navigatorKey: eventNavigateKey,
      ),
      customEvent: (BuildContext ctx) {
        print('object');
      },
    );
  }
}

class EventEx1 extends StatelessWidget {
  const EventEx1({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            TextButton(
                onPressed: () {
                  EventHelpers.showSnackBar('message');
                },
                child: const Text('snackbar')),
            TextButton(
                onPressed: () {
                  EventHelpers.navigate(
                    page: const EventEx2(),
                    navigateMethod: NavigationMethod.push,
                  );
                },
                child: const Text('navigate')),
            TextButton(
                onPressed: () {
                  EventHelpers.showDialog(
                    builder: (ctx) => const AlertDialog(
                      title: Text('title'),
                      content: Text('context'),
                    ),
                  );
                },
                child: const Text('dialog')),
            TextButton(
                onPressed: () {
                  EventHelpers.eventCustom();
                },
                child: const Text('dynamic')),
          ],
        ),
      ),
    );
  }
}

class EventEx2 extends StatelessWidget {
  const EventEx2({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: InkWell(
          onTap: () {
            EventHelpers.pop();
          },
          child: const Icon(Icons.arrow_back_ios),
        ),
      ),
      body: const Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('ex2'),
          ],
        ),
      ),
    );
  }
}
1
likes
150
points
15
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package offering a singleton broadcast event bus for easy global management of SnackBars, navigation, dialogs, and custom callbacks.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on ui_event_bus