01Inspect first Finds bootstrap, authentication, routing,
state management, and native configuration before editing.
02Integrate narrowly Adds one controller and the minimal
overlay without building another customer app.
03Verify the result Runs formatting, analysis, tests, and
supported platform builds before reporting success.
Preview the complete prompt ⌄
Integrate the RingDesk Flutter SDK into this existing Flutter application. Make the code changes and validate them; do not only describe the steps.
Before editing:
1. Inspect pubspec.yaml, the application bootstrap, routing, authentication/session lifecycle, current state-management pattern, Android configuration, iOS configuration, and relevant tests.
2. Identify where the signed-in user's stable opaque ID and display name are available. Never use an email address, phone number, or mutable display name as customerId.
3. Check whether ringdesk_flutter_sdk is already declared. If it is missing, run flutter pub add ringdesk_flutter_sdk to install it from pub.dev. Do not add a Git, branch, or local path override. If it is already declared, preserve its compatible version constraint unless dependency resolution proves a change is necessary.
Implementation requirements:
1. Preserve the existing UI, navigation, architecture, and state-management library. Do not create a replacement customer portal, calling screen, or new state-management layer.
2. Initialize RingDesk exactly once after WidgetsFlutterBinding.ensureInitialized using:
- const String.fromEnvironment('RINGDESK_DEVELOPER_ID')
- const String.fromEnvironment('RINGDESK_APP_CODE')
These are public identifiers. Never add an admin token, API secret, service-role key, or private credential to client code.
3. Create one application-lifetime RingDeskController with RingDeskController.initialized(). Put it in the existing root/service/provider lifecycle and dispose it only when that owner is destroyed.
4. Wrap the existing MaterialApp builder child with RingDeskOverlay. Keep the default draggable minimal controls. Use showLauncher: true only if the app has no existing Support button. If it has one, retain that button, create a RingDeskOverlayController, call startCall() from the button, and keep showLauncher: false.
5. Do not require customer data during application startup. After the host login succeeds, call controller.setCustomer with RingDeskCustomer(name: user display name, customerId: stable opaque auth user ID). Await controller.signOut() before completing logout or switching users.
6. Keep the default automatic call-permission policy unless the app already has a permission explanation screen. For a deferred flow, use RingDeskPermissionPolicy.deferred and call requestNecessaryPermissions after that explanation.
7. Never request or start screen capture at startup. App-only and entire-screen sharing must remain user-triggered and must use Android MediaProjection or iOS ReplayKit consent.
8. Android SDK permissions and foreground-service declarations should merge from the plugin. Do not add READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE, MANAGE_EXTERNAL_STORAGE, SYSTEM_ALERT_WINDOW, or custom background-start workarounds.
9. On iOS, add a clear NSMicrophoneUsageDescription and the audio and voip UIBackgroundModes. Add a ReplayKit Broadcast Upload Extension, shared App Group, and RTCScreenSharingExtension only if whole-device sharing is required; do not invent identifiers.
10. If file sharing is requested, expose only explicit application-owned absolute directories through RingDeskFileAccessRoot. Do not grant broad device storage access.
11. Keep Developer ID and App code supplied with --dart-define or the project's existing public build configuration. Do not hardcode environment-specific values.
Validation and acceptance criteria:
1. Run dart format on changed Dart files, flutter pub get, flutter analyze, and the relevant Flutter tests. Build Android and iOS without signing when the local toolchain supports them.
2. Add or update tests proving the original home/navigation UI remains present, customer identity attaches after login, logout clears RingDesk identity, and only one RingDesk launcher/control overlay exists.
3. Confirm there are no embedded secrets, no broad storage/overlay permissions, no automatic screen capture, and no unrelated UI or architecture rewrite.
4. Do not claim success when a command fails. Report changed files, commands and results, remaining native/manual steps, and any value I still need to provide.
Paste into your coding assistant, then answer only what it cannot discover itself.