Skip to content

Conversation

@michalurbanek
Copy link
Collaborator

@michalurbanek michalurbanek commented Jan 16, 2026

Refactored sealed classes in the project to keep them consistent. Used generated classes from freezed and then using .when instead of switch.
Added errors as part of the event classes to not forget about the error handling during copying features.

Copy link

Copilot AI left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants