Skip to content

Use new ScreenControllers class for controller lifecycle management - #8908

Merged
kenzieschmoll merged 21 commits into
flutter:masterfrom
kenzieschmoll:new-controllers
Feb 20, 2025
Merged

kenzieschmoll merged 21 commits into
flutter:masterfrom
kenzieschmoll:new-controllers

Conversation

@kenzieschmoll

Copy link
Copy Markdown
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 a team, bkonyi and elliette as code owners February 19, 2025 00:28
Comment thread packages/devtools_app/lib/src/screens/debugger/breakpoints.dart
Comment thread packages/devtools_app/lib/src/screens/debugger/breakpoints.dart Outdated
Comment thread packages/devtools_app/lib/src/screens/debugger/codeview.dart Outdated
Comment thread packages/devtools_app/lib/src/shared/framework/screen_controllers.dart Outdated
Comment thread packages/devtools_app/lib/src/shared/framework/screen_controllers.dart Outdated
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