v1: Auto-registering of services#5600
Merged
FeodorFitsner merged 11 commits intomainfrom Aug 30, 2025
Merged
Conversation
Introduces the ServiceHost control in both Dart and Python SDKs, enabling hosting and management of services for child controls. Updates documentation, mkdocs navigation, and core extension registration to support ServiceHost.
Implemented the __call__ method in the Ref class to allow instances to be called directly, returning the current referenced object. This enhances usability and provides a more intuitive API.
Corrected image and anchor links in documentation for tabs and Android publishing. Updated type annotations and return types in cache.py for clarity. Fixed indentation in docstrings for alert_dialog.py and chip.py.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a ServiceHost control to both the Dart and Python SDKs, enabling lifecycle management of hosted services. It also includes several API improvements and documentation fixes.
- ServiceHost control implementation for managing service lifecycles and exposing them to child controls
- Enhanced Ref control with callable interface for direct value access
- Improved type annotations and proper service disposal in ServiceRegistry
Reviewed Changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/python/packages/flet/src/flet/controls/ref.py | Added __call__ method to Ref for direct value retrieval |
| sdk/python/packages/flet/src/flet/controls/core/service_host.py | New ServiceHost control implementation in Python |
| sdk/python/packages/flet/src/flet/controls/cache.py | Improved typing for cache decorator return signature |
| sdk/python/packages/flet/src/flet/init.py | Added ServiceHost to Python package exports |
| packages/flet/lib/src/services/service_registry.dart | Added dispose method for proper service cleanup |
| packages/flet/lib/src/controls/service_host.dart | New ServiceHost control implementation in Dart |
| packages/flet/lib/src/flet_core_extension.dart | Registered ServiceHost control and reorganized switch cases |
| sdk/python/packages/flet/mkdocs.yml | Added ServiceHost documentation to navigation |
| sdk/python/packages/flet/docs/controls/servicehost.md | Created ServiceHost documentation page |
| sdk/python/packages/flet/docs/publish/android.md | Fixed broken reference link |
| sdk/python/packages/flet/docs/controls/tabs/index.md | Fixed broken image path |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
sdk/python/packages/flet/src/flet/controls/core/service_host.py
Outdated
Show resolved
Hide resolved
Corrected grammar in the ServiceHost class docstring from 'make' to 'makes' for clarity.
Deploying flet-docs with
|
| Latest commit: |
937f0e9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://270b4eda.flet-docs.pages.dev |
| Branch Preview URL: | https://v1-servicehost.flet-docs.pages.dev |
Replaces 'services' with '_services' in ServiceRegistry and updates related references for encapsulation. Introduces thread safety and cleanup for unreferenced services. Refactors auto-update logic to use a unified 'after_event' method, simplifying event handling and service lifecycle management. Improves error handling in context and updates property access patterns for services in Page.
Updated the Dart PageControl to initialize ServiceRegistry with the main control instead of its child, simplifying service management. In Python, replaced the _page_services ServiceRegistry with a direct _services list, updating references and related tests for consistency.
Deleted the ServiceHost control implementation, its documentation, and references from mkdocs navigation and __init__.py. This change removes ServiceHost from the public API and documentation, likely due to deprecation or refactoring.
Deleted the ServiceHostControl widget and its import and usage from flet_core_extension.dart. This refactor removes support for the ServiceHost control, likely due to deprecation or architectural changes.
ServiceHost controlDeleted the unused 'bind' method from the Page class to clean up the codebase and improve maintainability.
Refactored the ServiceRegistry method name from cleanup to unregister_services for clarity. Updated references in session.py to use the new method name.
Deleted the unused ModelT TypeVar declaration to clean up the code in page.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #5506
Services can now be used right away, without adding them to
page.services, for example: