-
Notifications
You must be signed in to change notification settings - Fork 7
refactor: Sealed Classes #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors sealed classes across the project to use private implementation classes (prefixed with _) generated by freezed and replaces pattern matching with switch statements with the .when() and .maybeWhen() methods. Additionally, it adds error handling to event classes to ensure errors are properly handled when copying features.
Changes:
- Replaced public freezed implementation class names (e.g.,
ProfileEventSignedOut) with private ones (e.g.,_SignedOut) - Converted switch-based pattern matching to
.when(),.maybeWhen(), and.whenOrNull()methods - Added error event variants to authentication, profile, and debug tools event classes
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/features/profile/profile_page.dart | Updated event listener to use .when() method and added error handling |
| lib/features/profile/profile_event.dart | Changed to private implementation classes and added error event |
| lib/features/debug_tools/page/widgets/debug_tools_widgets_page_event.dart | Changed to private implementation classes and added error event |
| lib/features/debug_tools/page/widgets/debug_tools_widgets_page_content.dart | Updated event listener to use .when() method and added error handling |
| lib/features/authentication/authentication_state.dart | Replaced switch pattern with .maybeWhen() for exception handling |
| lib/features/authentication/authentication_page.dart | Updated event listener to use .when() method and added error handling |
| lib/features/authentication/authentication_event.dart | Changed to private implementation classes and added error event |
| lib/core/analytics/analytics_screen_view.dart | Simplified to use private classes with default parameter values |
| lib/common/validator/text_field_validator_state.dart | Changed to private classes and replaced getters/methods with .when() variants |
| lib/common/validator/controller/text_validator_controller_general.dart | Simplified to use state's isValid getter directly |
| lib/common/usecase/authentication/sign_in_with_auth_credential_use_case.dart | Replaced switch pattern with .whenOrNull() |
| lib/common/provider/notifications_service.dart | Replaced switch statements with .when() method |
| lib/common/data/entity/notification_payload_entity.dart | Simplified to private classes, removed default values from unknown variant |
| lib/common/data/entity/exception/validator_exception.dart | Refactored to use shared getText field and simplified getMessage |
| lib/common/data/entity/exception/custom_exception.dart | Changed to private classes and replaced switch with .maybeWhen() |
| README.md | Removed completed TODO item about sealed classes refactor |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Refactored sealed classes in the project to keep them consistent. Used generated classes from freezed and then using
.wheninstead ofswitch.Added errors as part of the event classes to not forget about the error handling during copying features.