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

Use new ScreenControllers class for controller lifecycle management #8908

Merged
merged 21 commits into from
Feb 20, 2025

Conversation

kenzieschmoll
Copy link
Member

We used to use package:provider to manage the lifecycle of the DevTools screen controllers, and ProvidedControllerMixin as a way to easily initialize and access these controllers. This caused lifecycle management issues and memory leaks because the screen controllers (which are expected to be long living) were tied to the widget lifecycle, since lookup controllers up from package:provider requires access to BuildContext.

This PR creates a class ScreenControllers that is accessible from a global screenControllers. Individual screen controllers are still created lazily upon first access, and can be accessed from anywhere (widget code or business logic) by calling screenControllers.lookup<ControllerType>().

This PR also deletes the ProvidedControllerMixin since it is no longer needed.

@kenzieschmoll kenzieschmoll requested review from bkonyi, elliette and a team as code owners February 19, 2025 00:28
@kenzieschmoll kenzieschmoll merged commit 616a363 into flutter:master Feb 20, 2025
41 checks passed
@kenzieschmoll kenzieschmoll deleted the new-controllers branch February 20, 2025 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants