Skip to content

feat: provide CallController as singleton via RepositoryProvider in MainShell#1000

Open
SERDUN wants to merge 4 commits intodevelopfrom
feature/call-controller-singleton
Open

feat: provide CallController as singleton via RepositoryProvider in MainShell#1000
SERDUN wants to merge 4 commits intodevelopfrom
feature/call-controller-singleton

Conversation

@SERDUN
Copy link
Member

@SERDUN SERDUN commented Mar 13, 2026

Summary

  • Introduce CallControllerScope (InheritedWidget) following the PresenceViewParams pattern already in the codebase — semantically correct alternative to RepositoryProvider for a UI-tier coordinator
  • Register a single CallController instance in MainShell (stored in _MainShellState via ??= to survive rebuilds) and expose it via CallControllerScope
  • Remove per-widget instantiation from 7 call sites; each State now caches the shared instance with late final _callController = CallControllerScope.of(context)
  • Remove now-unused imports (NotificationsBloc, notifications.dart) from affected files

Test plan

  • Existing call_controller_test.dart (8 tests) — all pass
  • Manual: place a call from Keypad, Recents, Favorites, Contacts, Chat dialog info, CDR list (full & missed)

…ainShell

Register CallController once in MainShell widget tree after CallBloc,
CallRoutingCubit and NotificationsBloc are available. All seven call
sites now obtain the shared instance via late final field initializer
(context.read<CallController>()) instead of constructing a new object
per StatefulWidget.
@SERDUN SERDUN added the draft Not ready but can be start to review label Mar 13, 2026
@SERDUN SERDUN requested a review from Copilot March 13, 2026 13:05

This comment was marked as resolved.

…dget

RepositoryProvider is semantically for the data layer; CallController
is a UI-tier coordinator. Introduce CallControllerScope (InheritedWidget)
following the PresenceViewParams pattern already in the codebase.
All seven consumers now resolve the controller via CallControllerScope.of(context).

This comment was marked as resolved.

SERDUN added 2 commits March 13, 2026 16:10
Store CallController in _MainShellState via ??= so it is created once
regardless of how many times build() reruns. Switch CallControllerScope.of
to getElementForInheritedWidgetOfExactType to avoid registering a rebuild
dependency that would never fire (updateShouldNotify is always false).
@SERDUN SERDUN removed the draft Not ready but can be start to review label Mar 13, 2026
@SERDUN SERDUN requested a review from digiboridev March 13, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants