As shared capabilities serve more products, product-specific requirements can accumulate in the common implementation. The central design problem is defining module boundaries that accommodate product-specific changes and a clear scope of responsibility for shared capabilities.
This note examines module interfaces, runtime injection, and lifecycle management implemented in a shared Flutter package. The focus is on code reuse alongside independent product UI and behavior rules.
Separating domain logic from shared services
Product-specific behavior resides in modules, while persistence, settings, event recording, and diagnostics are provided through a shared runtime. The module interface defines preloading, view construction, pause and resume, and session termination results. Execution control invokes this interface; each module implements behavior and results according to its own rules.
Responsibilities and reasons for change determine what is shared. The separation aims to accommodate product-rule changes without modifying shared services. Changes to interfaces or storage formats still require compatibility review on both sides.
Domain logic · Views · Outcome evaluation
Preload · Build view · Pause/resume · End
Execution control · Persistence · Settings · Events · Diagnostics
Execution control invokes the interface; the module uses the runtime passed to it.
Separating the application shell from lifecycle management
Bootstrap initializes the runtime and passes it to the product’s app builder. The product retains its own application shell and routing, embedding an execution host in the appropriate view. The host delegates preloading and app-state-driven pause and resume to the module. Navigation and completion UI remain product-owned.
The shared shell used by internal prototypes did not fully accommodate independent app layouts. During preparation for external app integration, we added this connection to separate lifecycle management from screen composition.
The integration model uses public package APIs and pins the dependency version for each product. Shared-package changes are introduced through explicit product upgrades and verification. Alongside source separation, adoption timing is managed per product.
Verifying module addition and external integration
Verification used two mobile-game prototypes with different rules and a separate Flutter test project.
- Module addition: The second prototype implemented its own rules and outcome evaluation while reusing execution, persistence, and event recording without shared-core changes.
- Behavior verification: Widget tests checked completion, failure, retry, progress persistence, and event recording.
- External integration: Code generated by the package’s public tools in a separate Flutter project passed analysis and tests.
These results establish reuse for the tested modules and external integration path. Different applications require a fresh review of data structures, lifecycle, and UI requirements. Production performance and data-migration verification remain product-specific work.
Applying this to your service
Every service has its own screens and ways of working. When building a new service or improving an existing one, we review which capabilities can be shared while preserving those differences. Later feature additions can also be scoped by identifying what needs to be built, what can be retained, and which existing functions need to be checked alongside the changes.