Register all foundation providers in app bootstrap
epic-screen-reader-support-foundation-task-013 — Register the five foundation Riverpod providers (SensitiveFieldConfigurationRegistry, AccessibilitySettingsRepository, SemanticsServiceFacade, ScreenReaderDetectionService, and the SemanticsWrapperWidget theme extension) in the app's ProviderScope at bootstrap. Ensure ScreenReaderDetectionService initialises before first frame and WidgetsBindingObserver is attached for foreground re-evaluation.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
In main.dart, after WidgetsFlutterBinding.ensureInitialized() and existing Supabase/BankID init, add a call to bootstrap the accessibility foundation: create a top-level initAccessibilityFoundation() async function in lib/accessibility/bootstrap.dart that (1) reads ScreenReaderDetectionService from a temporary ProviderContainer, (2) calls initialize(), and (3) attaches WidgetsBindingObserver. Use ProviderScope at the root of runApp() — do not create a separate ProviderContainer for the app. For eager initialisation of ScreenReaderDetectionService, use ref.read(screenReaderDetectionServiceProvider).initialize() inside a Provider.overrideWithValue or an app-level ConsumerStatefulWidget initState. The cleanest pattern is an AppStartup ConsumerStatefulWidget that calls the init in initState and shows a loading indicator until done — this pattern is already common in Riverpod apps.
Ensure the WidgetsBindingObserver is removed in the service's dispose() method to prevent memory leaks when the provider is invalidated.
Testing Requirements
Smoke test: run the app in debug mode on an iOS simulator with VoiceOver enabled and confirm ScreenReaderDetectionService emits true within the first frame. Run on Android emulator with TalkBack enabled and confirm the same. Write a widget test that bootstraps the full ProviderScope (as in task-012 integration test) and confirms all five providers are accessible immediately after the first frame (tester.pump()). Confirm no errors appear in the debug console on cold start.
If CI runs integration tests, add a startup smoke test to the integration_test/ suite that reads all five providers and asserts non-null values.
Flutter's SemanticsService behaves differently between iOS (VoiceOver) and Android (TalkBack) in edge cases — e.g., announcement queuing, focus-gain timing, and attribute support. If the facade does not correctly abstract these differences, announcements may be silent or misfired on one platform, causing regression on the other platform to go unnoticed until device testing.
Mitigation & Contingency
Mitigation: Write platform-divergence unit tests early using SemanticsServiceFacade mocks. Validate announcement delivery on a physical iPhone (VoiceOver) and Android device (TalkBack) at the end of each sprint. Document known platform differences in the facade's inline API comments.
Contingency: If a platform difference cannot be abstracted cleanly, expose a platform-specific override path in the facade and implement targeted workarounds per platform, accepting the added complexity in exchange for correct behaviour.
Accessibility preferences stored in local storage may need new fields as higher-tier epics are implemented (e.g., announcement verbosity, sensitive-field guard toggle). Schema changes to an already-persisted store risk data migration failures or silent defaults on existing installs, breaking user preferences.
Mitigation & Contingency
Mitigation: Design the AccessibilitySettingsRepository with a versioned JSON schema from the start, using merge-with-defaults on read so new fields fall back gracefully. Define the full expected field list upfront based on all downstream epic requirements before writing the first record.
Contingency: If migration fails on a live install, fall back to full reset-to-defaults with a one-time in-app notification informing the user that accessibility preferences have been reset and inviting them to reconfigure.