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

Refactor state.dart (part 2) #596

Closed
wants to merge 50 commits into from
Closed

Refactor state.dart (part 2) #596

wants to merge 50 commits into from

Conversation

d-uzlov
Copy link
Contributor

@d-uzlov d-uzlov commented Oct 29, 2022

Closes #556

This is a huge pull request, which is not ideal.
If I had enough time I would split it into several small PRs which would be much easier to review.
However, I think it's very important to merge it. I believe that this PR contains a significant code quality improvement (which I was thinking about for the last several months).

@github-actions
Copy link

github-actions bot commented Oct 29, 2022

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@d-uzlov d-uzlov requested a review from anhappdev October 30, 2022 18:28
Comment on lines +93 to +101
// All methods in AppState should have the following properties:
// - Public methods: return type `void`, public methods must not be awaited
// - Public methods: exceptions are never thrown
// - All methods: notifyListeners() call outside of `state` setter is forbidden
// - All methods: if notifyListeners() is needed when `state` field doesn't change,
// the class that contains the data that requires UI update should implement ChangeNotifier instead
// - All methods: complex logic should be moved to other classes, methods in AppState should only manage `state`
//
// Any methods or getters that don't satisfy these requirements should be subject to refactoring.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anhappdev, the #556 issue and this whole PR in particular was for these rules.
Other changes may be subject to discussions, but I think these few lines are very important.
Everything else in this PR was changed to make this possible. Even though there are still few little things left in this class that don't obey these rules, now it will be easy to fix it.

…ctor-state-2

# Conflicts:
#	flutter/lib/state/task_runner.dart
@sonarcloud
Copy link

sonarcloud bot commented Oct 31, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@freedomtan
Copy link
Contributor

close this for now. We prefer piecemeal changes. Maybe we can cherrypick some small ones from this huge one later.

@freedomtan freedomtan closed this Nov 1, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor state.dart file
2 participants