Overview of the mayr_events package structure and organization.
mayr_flutter_events/
├── lib/ # Source code
│ ├── src/ # Implementation files
│ │ ├── mayr_event.dart # Base event class
│ │ ├── mayr_listener.dart # Base listener class
│ │ ├── mayr_events.dart # Event bus implementation
│ │ └── mayr_event_setup.dart # Setup/configuration class
│ └── mayr_events.dart # Main export file
│
├── test/ # Tests
│ ├── mayr_events_test.dart # Complete test suite (350+ lines)
│ └── simple_test.dart # Standalone verification test
│
├── example/ # Example Flutter app
│ ├── lib/
│ │ └── main.dart # Interactive demo app
│ ├── pubspec.yaml
│ └── README.md # Example documentation
│
├── docs/ # Documentation
│ ├── API.md # API reference (~450 lines)
│ ├── QUICKSTART.md # 5-minute tutorial
│ ├── TESTING.md # Testing guide
│ ├── CONTRIBUTING.md # Contribution guidelines (~270 lines)
│ └── DESIGN.md # Architecture and design
│
├── .github/
│ └── workflows/
│ └── ci.yaml # GitHub Actions CI
│
├── pubspec.yaml # Package configuration
├── analysis_options.yaml # Dart analyzer config
├── CHANGELOG.md # Version history
├── LICENSE # MIT License
├── README.md # Main documentation
└── test.sh # Test convenience script
Main entry point that exports all public APIs. This is what users import.
library mayr_events;
export 'src/mayr_event.dart';
export 'src/mayr_listener.dart';
export 'src/mayr_events.dart';
export 'src/mayr_event_setup.dart';Defines the base MayrEvent class. All events must extend this class.
Key points:
- Abstract base class
- Designed for immutability (const constructor)
- Simple by design (no built-in functionality)
Defines the base MayrListener<T> class. All listeners must extend this class.
Key points:
- Generic type parameter for event type
- Properties:
once,queued,runInIsolate - Abstract
handle()method
The event bus implementation. Manages all listeners and fires events.
Key points:
- Singleton pattern (
instancestatic property) - Type-safe listener registration
- Async event firing
- Error handling and hooks support
- Utility methods (remove, clear, count, etc.)
Base class for application-level event configuration.
Key points:
- Abstract class to be extended by user
registerListeners()- Where user registers all listenersbeforeHandle()andonError()hooksinit()- Initializes the event system
Comprehensive test suite using Flutter's test framework.
Coverage:
- Unit tests for each component
- Integration tests
- Edge cases (once-only, errors, etc.)
- Hooks testing
- ~350 lines of tests
Simplified standalone test for quick verification.
Purpose:
- Can run without full Flutter setup
- Quick smoke tests
- Development verification
Complete working Flutter application demonstrating all features.
Demonstrates:
- Event and listener definition
- MayrEventSetup usage
- Multiple events and listeners
- Once-only listeners
- beforeHandle and onError hooks
- UI integration
Complete API reference with examples and best practices.
Contains:
- Full API documentation for all classes
- Method signatures and parameters
- Usage examples
- Best practices
- Common patterns
5-minute tutorial for new users.
Covers:
- Installation
- Basic setup
- First event and listener
- Common patterns
- Next steps
Testing guide for contributors and users.
Includes:
- How to run tests
- Test structure
- Writing new tests
- CI information
- Troubleshooting
Comprehensive contribution guidelines.
Covers:
- Code of conduct
- How to contribute
- Development setup
- Coding guidelines
- Commit message format
- PR process
Architecture and design decisions.
Contains:
- Core concepts
- Architecture overview
- Design rationale
- Example usage
Package metadata and dependencies.
Key sections:
- Package name:
mayr_events - Dependencies: Flutter SDK
- Dev dependencies: flutter_test, flutter_lints
- Metadata: description, homepage, repository, etc.
Dart analyzer configuration.
Settings:
- Includes
flutter_lintspackage - Enforces Flutter best practices
GitHub Actions CI configuration.
Steps:
- Checkout code
- Setup Flutter
- Install dependencies
- Run tests
- Format check
- Analyze code
- Source files: snake_case (e.g.,
mayr_event.dart) - Test files: Suffix with
_test.dart - Documentation: UPPERCASE.md for important docs, PascalCase.md for guides
- Core classes in separate files
- Tests mirror source structure
- Examples separate from library
- Core functionality is simple
- Advanced features are opt-in
- Documentation progressive (README → QUICKSTART → API)
- Clear entry points
- Comprehensive examples
- Multiple documentation levels
- Easy to test
- Small, focused files
- Clear dependencies
- Comprehensive tests
- Well-documented
When adding features to mayr_events:
- Add implementation in
lib/src/ - Export from
lib/mayr_events.dart - Add tests in
test/mayr_events_test.dart - Document in:
- Dartdoc comments (in code)
- API.md (API reference)
- QUICKSTART.md (if user-facing)
- README.md (if major feature)
- Update example if applicable
- Update CHANGELOG.md
The following directories are excluded from version control:
.dart_tool/- Pub/Dart tooling cachebuild/- Build outputscoverage/- Test coverage reports.flutter-plugins-dependencies- Flutter plugin cache
- Clone repository
- Run
flutter pub get - Make changes
- Run
./test.shto verify - Commit changes
- Push to fork
- Create pull request
- Unit tests for individual components
- Integration tests for workflows
- Example app for manual testing
- CI for automated testing
- Inline docs (dartdoc) for API
- README for overview and quick examples
- QUICKSTART for tutorials
- API.md for complete reference
- Other .md files for specific topics
For more information, see: