cometchat-flutter-v6-patterns
Project wiring for the Flutter v6 UI Kit — navigation (Navigator / go_router / auto_route), state management (bloc / riverpod / provider / getx), config & secrets, platform setup, and web/desktop caveats. Triggers: 'cometchat with go_router', 'cometchat with riverpod', 'where do I put init in flutter', 'dart-define cometchat', 'cometchat flutter web'.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 1.6k
- Forks
- 474
01 前言 Front Matter
- name
- cometchat-flutter-v6-patterns
- license
- MIT
- metadata
- { "tags": "cometchat flutter patterns navigation state-management go-router riverpod config v6", "author": "CometChat", "version": "1.0.0" }
- description
- Project wiring for the Flutter v6 UI Kit — navigation (Navigator / go_router / auto_route), state management (bloc / riverpod / provider / getx), config & secrets, platform setup, and web/desktop caveats. Triggers: 'cometchat with go_router', 'cometchat with riverpod', 'where do I put init in flutter', 'dart-define cometchat', 'cometchat flutter web'.
- compatibility
- Flutter >=3.38.9; cometchat_chat_uikit ^6 (6.1.x, verified 6.1.0)
03 SKILL.md 正文
Ground truth: the CometChat side is
cometchat-flutter-v6-core; this skill only adds the DELTA for a given toolchain. Framework mechanics (go_router, riverpod,--dart-define) are baked Flutter knowledge, not kit API. Kit symbols come from the catalog.
Companion skills (read first)
cometchat-flutter-v6-core— install, credentials, the settings asset,init→login→render. This skill ASSUMES it.cometchat-flutter-v6-placement— WHERE the surface goes; this skill is HOW it hooks into your app's plumbing.
Use this skill when
Wiring the kit into a specific project shape, or debugging "where does init go" / "the theme resets on navigation" / "my secrets are in git".
Prerequisites & install
Covered by core. No new package.
Navigation (BAKED — the delta per router)
The kit uses plain Navigator.push/pop internally and in every recipe, which works under all of these — you do not have to convert its recipes.
- Plain
Navigator— nothing to do. Core's recipes are already this. go_router— register chat screens as routes and push withcontext.push('/chat/:uid'). The kit's own internal pops still work because go_router sits on the sameNavigator. Put the init/login gate above the router (wrapMaterialApp.router's builder, or gate inredirect) so no chat route can build before login resolves.auto_route— same principle: anAutoRouteGuardthat waits for login is the idiomatic gate.- Calling adds one requirement:
navigatorKey: CallNavigationContext.navigatorKeyonMaterialApp(→-calls). Withgo_router, pass the same key into the router config rather than creating a second one.
State management (BAKED)
The kit is self-contained — every widget drives its own BLoC internally. You do not wire the kit into your app's state layer, and you do not need flutter_bloc yourself.
- bloc / cubit — expose the logged-in user from your auth cubit; gate chat routes on it. Do not try to own the kit's internal blocs.
- riverpod — a
FutureProviderthat performsinitFromSettings+loginand which chat screens.when(...)on, is the cleanest gate. - provider / getx — same shape: one async init future, everything chat-related below it.
- Reading kit state —
CometChatUIKit.loggedInUseris the sync getter. For list state, use the widget'sstateCallBack/onLoad, not a global store.
Config & secrets (BAKED — Flutter-specific)
initFromSettings reads a bundled asset, so it cannot read --dart-define. Two honest options; state the trade-off and let the user choose:
- Keep
initFromSettingsand generatecometchat-settings.jsonat build time from your existing secret source (CI writes the file). KeepsintegrationSource="ai-agent"telemetry. - Use the classic
UIKitSettingsBuilder+CometChatUIKit.init(...)with--dart-definevalues. Works, but loses telemetry attribution.
Either way the Auth Key ends up in the app bundle and is dev-only — production means a server-minted auth token +
loginWithAuthToken(core'slifecycle.md). Do NOT gitignore the registeredcometchat-settings.jsonasset (a fresh clone / CI build then fails with "No file or variants found for asset") — commit a placeholder version (no real Auth Key) that dev/CI overwrite, and guard the real key with a pre-commit/CI check.
Platform setup (BAKED)
- Android —
minSdk = 26inandroid/app/build.gradle.kts(the docs' 24 is too low); INTERNET permission; calling adds camera/mic. - iOS —
platform :ios, '15.1'in the Podfile, thenpod install; photo/camera/mic usage strings for attachments and calls. Both floors come fromcometchat_calls_sdk, which the kit depends on unconditionally — they apply whether or not you use calling (DOCS-BACKLOG D7). - Web — the kit supports web, but plugin-backed features (media picker, calling) behave differently; verify anything you promise.
flutter run -d chromewith the same settings asset. - Desktop — not a documented target; if asked, say so honestly rather than guessing.
Common pitfalls (BAKED)
- Init inside a screen that can be re-entered (or inside a route builder) → repeated init. Gate ONCE at the root (
lifecycle.md). - A chat route reachable before login resolves → blank screen. Guard the route, not just the widget.
- Expecting
initFromSettingsto read--dart-define— it reads an asset. See above. - Adding
flutter_blocto "connect" the kit — unnecessary; the kit owns its blocs. - Two navigator keys when calling is on — the router and
CallNavigationContextmust share one. cometchat-settings.jsoncommitted — the Auth Key is in your repo.- Forgetting
WidgetsFlutterBinding.ensureInitialized()before an asset-reading init.
Verify it works
The app builds on each target platform you claim; chat routes are unreachable until login resolves; navigating away and back does not re-init; secrets are not in git; with calling on, an incoming call presents from any route.
04 同仓库更多 Skills
migrate-to-e2e
Moves an existing Playwright, Cypress, Selenium, Appium, Detox, Maestro, or TesterArmy suite to e2e one slice at a time, with the old suite running beside the new one until each ported test is proven. Keeps a MIGRATION.md progress file so any later session resumes where the last stopped. Optionally plants a defect to show both suites catch it. Use for /migrate-to-e2e, "migrate our tests to e2e", "port these Maestro flows", "move our TesterArmy tests", or when a project has an e2e config and an older suite still running.
e2e
Writes, runs, and debugs end-to-end tests for web and mobile apps with e2e, the agentic test runner, which mixes agent.act goals with exact locator assertions on a Playwright browser or an iOS or Android device. Also drives a project's running app live over the e2e MCP server to look at a screen, check a UI change, take a screenshot or record a video, and try a locator; and runs bug bashes, parallel e2e explore runs with each bug proven by a repro test. Use when a project depends on e2e or has an e2e.config.ts, when asked for end-to-end, browser, mobile, or agentic UI tests, to check a change in the running app, to QA or bug bash an app or branch, or when an e2e run fails.
create-verification-skill
Generate a project-local verify-<app> skill on top of e2e, so any coding agent can launch the app, check it is worth driving, exercise a feature the way a user does, keep evidence, and bug bash it. Writes the skill, a feature map with one explore charter per feature, and proves it once. Use for /create-verification-skill, "make a verification skill for this repo", or when a project has no scripted way to prove UI behavior.
deja-search
deja-vu memory — search the user's past AI coding sessions with the deja CLI. Holds what they already settled and never wrote into the repo (naming rules, banned or already-tried tools, required checks before merge, preferred values, who owns what). Use before your first edit in a task, before you call a change done or ready to merge, before you recommend a tool, library, design or reviewer, before re-debugging an error that may already be solved, when they say 'didn't we fix this before', 'what did we decide about X' or 'I already have that', and before telling them something on this machine does not exist.
deja-reflect
End-of-session reflection and memory curation with deja-vu. Review what was decided, what commands broke and what repaired them, and record durable project rules or decisions with deja remember so the next session starts with them.
revid
Make, edit, export and post AI videos with Revid (revid.ai) through the Revid MCP server. Use whenever the user wants a short-form or long-form video made (from an idea, a script, a URL, an article, a PDF, a tweet, a product page, their own clips, or a song), wants to find what is going viral on TikTok, YouTube, Instagram or X before making something, wants to edit or re-export an existing Revid project, generate a standalone AI image or clip, make a series episode, or publish and schedule a finished video to connected social accounts. Covers setup (hosted MCP with OAuth, or an API key), the 36 tools, credits, polling and the rules for publishing. Routes to the more specific revid-* skills when one fits.