Skip to content
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

feat: refactor Health class to remove singleton pattern and enable dependency injection for DeviceInfoPlugin #1114

Merged
merged 6 commits into from
Jan 15, 2025

Conversation

iarata
Copy link
Contributor

@iarata iarata commented Jan 9, 2025

This PR removes the singleton pattern and allows for dependency injection for the DeviceInfoPlugin. Additionally, it updates the example application to reflect these changes.

  • Dependency Injection for DeviceInfoPlugin:

    • The Health class is no longer a singleton and the Health() factory constructor is removed.
    • The Health class now accepts an optional DeviceInfoPlugin dependency through its constructor to facilitate easier mocking during unit tests. [1] [2]
  • Global Instance Initialization:

    • A global instance of the Health class is created and used throughout the example application instead of calling Health() multiple times.
    • Updated all method calls in _HealthAppState to use the global health instance. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]
  • Added mocktail as a development dependency in pubspec.yaml to support mocking in unit tests.

@iarata iarata requested a review from bardram January 9, 2025 13:20
@iarata iarata requested review from SlimShadyIAm and removed request for SlimShadyIAm January 12, 2025 11:09
Copy link
Contributor

@bardram bardram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@bardram bardram merged commit 594322e into iarata/health-12 Jan 15, 2025
1 check passed
@bardram bardram deleted the health-12/test branch January 15, 2025 16:30
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