Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
9945031
feat(firebaseai): deprecate imagen (#18148)
cynthiajoan Mar 27, 2026
ac207eb
chore(ci): Add flutter&Dart AI rules for Gemini Review bot, Gemini CL…
cynthiajoan Mar 30, 2026
b03782b
chore(deps): bump node-forge in /.github/workflows/scripts/functions …
dependabot[bot] Mar 30, 2026
f503961
chore(deps): bump path-to-regexp in /.github/workflows/scripts/functi…
dependabot[bot] Mar 30, 2026
81f3032
feat(app_check, windows): add support for AppCheck for Windows (#18140)
Lyokone Mar 30, 2026
b3ab000
feat: bump JS SDK to version 12.11.0 (#18160)
Lyokone Apr 2, 2026
2664b2c
feat: bump iOS SDK to version 12.11.0 (#18161)
Lyokone Apr 2, 2026
7d32374
chore(deps): bump dart-lang/setup-dart from 1.7.1 to 1.7.2 (#18162)
dependabot[bot] Apr 2, 2026
f701b1a
chore(deps): bump ossf/scorecard-action from 2.4.0 to 2.4.3 (#18163)
dependabot[bot] Apr 2, 2026
3f06afb
chore(deps): bump bluefireteam/melos-action (#18164)
dependabot[bot] Apr 2, 2026
502dd0e
chore(deps): bump actions/setup-go from 5.3.0 to 6.4.0 (#18165)
dependabot[bot] Apr 2, 2026
e9c99ef
chore(deps): bump actions/cache from 4.2.0 to 5.0.4 (#18166)
dependabot[bot] Apr 2, 2026
bb1e04f
feat(firebaseai): add spm support for firebase_ai, and update example…
cynthiajoan Apr 2, 2026
4b8f228
feat(firebaseai): server prompt chat and function calling (#17972)
cynthiajoan Apr 3, 2026
501168a
chore(deps): bump lodash in /.github/workflows/scripts/functions (#18…
dependabot[bot] Apr 7, 2026
752cbca
fix(auth, ios): serialize Sign in with Apple to prevent crash on over…
SelaseKay Apr 7, 2026
a63bd2a
docs(auth): enhance iOS phone authentication error handling and setup…
SelaseKay Apr 8, 2026
3c29048
fix: improve error handling in _firebaseExceptionFromCoreFirebaseErro…
SelaseKay Apr 9, 2026
1a20154
chore(firebaseai): update example to merge multimodel and add nano ba…
cynthiajoan Apr 9, 2026
55a7f6f
fix(crashlytics,android): fix an issue with deobfuscating flavored bu…
Lyokone Apr 10, 2026
6ce6f6b
feat(fdc): Streaming implementation for data connect (#18174)
aashishpatil-g Apr 13, 2026
3d943ed
feat: bump JS SDK to version 12.12.0 (#18186)
SelaseKay Apr 13, 2026
cc063bd
feat: bump Firebase iOS SDK to 12.12.0 (#18187)
SelaseKay Apr 13, 2026
346a048
feat(core): bump Firebase Android SDK to 34.12.0 (#18185)
SelaseKay Apr 13, 2026
d734cf0
feat: support for Firestore Pipelines (#18183)
SelaseKay Apr 13, 2026
2785272
feat(ai): add unexpectedToolCall finish reason and corresponding test…
SelaseKay Apr 13, 2026
c986356
chore(release): publish packages (#18189)
Lyokone Apr 13, 2026
385d933
feat(firebaseai): add Google Maps Grounding support (#18144)
ryanwilson Apr 13, 2026
90d2e1f
ci: fix swift check (#18190)
SelaseKay Apr 14, 2026
889af7c
feat(ai): add missing enum types (#18198)
Lyokone Apr 15, 2026
4c17ca8
fix(fdc): remove unused logs (#18197)
Lyokone Apr 16, 2026
1f1b4f0
chore(deps): bump protobufjs (#18203)
dependabot[bot] Apr 17, 2026
7e0a222
feat(auth,android): add revokeAccessToken support for Android (#18206…
Daeon97 Apr 20, 2026
9f32c61
fix(functions, web): dartify results from cloud function stream (#18212)
SelaseKay Apr 20, 2026
cb6b4ae
feat: upgrade pigeon to version 26.3.4 (#18205)
Lyokone Apr 21, 2026
15eb457
docs(auth): add Android access token revocation guide (#18215)
Daeon97 Apr 21, 2026
6cdfcb1
refactor: move all packages to workspace (#18182)
kevmoo Apr 21, 2026
865f03b
chore(fdc): Integration Tests for Websockets (#18216)
aashishpatil-g Apr 22, 2026
2711b61
chore(deps): bump protobufjs in /.github/workflows/scripts/functions …
dependabot[bot] Apr 23, 2026
39e5a80
chore(ci): nightly build and test setup (#18225)
cynthiajoan Apr 23, 2026
65d9bb7
refactor(database, android): simplify query handling by extracting qu…
SelaseKay Apr 24, 2026
918554c
chore(ci): nightly build, improve the way how workflows are triggered…
cynthiajoan Apr 24, 2026
c23dbad
chore(deps): bump fast-xml-parser (#18220)
dependabot[bot] Apr 27, 2026
a7eec5a
chore(ci): nightly build (#18229)
cynthiajoan Apr 27, 2026
4351179
fix(auth, iOS): update import path for autogenerated messages (#18227)
SelaseKay Apr 30, 2026
ea5bd20
chore: fix melos bs (#18234)
Lyokone Apr 30, 2026
b9c8a9e
fix(firestore,windows): fix CI issue (#18218)
Lyokone Apr 30, 2026
e8d712d
ci(fdc): improve CI for FDC (#18238)
Lyokone May 5, 2026
7c2fa5b
fix(auth, apple): remove incorrect paths in Package.swift files searc…
russellwheatley May 5, 2026
7ce191c
feat(core): Add Auth and AppCheck as App's registered service. (#18237)
cynthiajoan May 5, 2026
ab0b2f9
chore: update example dependencies across repo (#18219)
kevmoo May 6, 2026
829fd94
feat(firebaseai): live session resumption (#18038)
cynthiajoan May 6, 2026
2771f55
fix(storage,android): fix an issue that could happen when app would g…
Lyokone May 6, 2026
7d1a8b1
feat(firebaseai): ImageConfig and FinishReasons (#18180)
paulb777 May 6, 2026
851a1fe
chore(firebaseai): setup for mock response e2e test (#18029)
cynthiajoan May 6, 2026
40fd290
fix(database): fix a regression with database localEvents handling (#…
Lyokone May 7, 2026
2db3166
chore(deps): bump actions/setup-java from 4.5.0 to 5.2.0 (#18245)
dependabot[bot] May 7, 2026
57d4c3d
fix(messaging,android): fix call race that could happen when using re…
Lyokone May 7, 2026
b0bc6e8
fix(app_check): fix an issue with debug token that would sometime not…
Lyokone May 7, 2026
11bdedf
fix(database,android): fix an issue where setPersistenceEnabled neede…
Lyokone May 7, 2026
5a2afd2
chore(fdc): Use service classes to fetch auth and appcheck instances …
aashishpatil-g May 8, 2026
330bbb8
fix(fdc): block reconnecting if there are no active subscribers or pe…
aashishpatil-g May 8, 2026
7639f47
chore(deps): bump fast-xml-builder from 1.1.5 to 1.2.0 in /.github/wo…
dependabot[bot] May 11, 2026
f674ab0
chore(deps): bump actions/upload-artifact from 4.6.2 to 7.0.1 (#18242)
dependabot[bot] May 11, 2026
8c36c6c
chore(deps): bump ikalnytskyi/action-setup-postgres from 7 to 8 (#18243)
dependabot[bot] May 11, 2026
bea425d
chore(deps): bump actions/cache from 4.2.0 to 5.0.5 (#18244)
dependabot[bot] May 11, 2026
e23347b
fix(database,android): fix a regression where rapidly opening and clo…
Lyokone May 11, 2026
94f793d
chore(deps): bump reactivecircus/android-emulator-runner from 2.35.0 …
dependabot[bot] May 11, 2026
9783a44
fix(firestore, web): update Timestamp handling in jsify and EncodeUti…
SelaseKay May 11, 2026
a0de4ed
fix: update core, auth and app-check logic so internal resources on m…
russellwheatley May 11, 2026
8ff0a24
chore(release): publish packages (#18269)
russellwheatley May 11, 2026
67e3f89
chore(firebaseai): update sample model name (#18278)
cynthiajoan May 13, 2026
bb8ad54
feat: bump Firebase JS SDK to 12.13.0 (#18274)
SelaseKay May 14, 2026
d10e0ff
feat: bump Firebase android SDK to 34.13.0 (#18272)
SelaseKay May 14, 2026
78e10f0
feat: bump Firebase iOS SDK to 12.13.0 (#18273)
SelaseKay May 14, 2026
7c1257e
fix(core, iOS): use namespaced iOS Pigeon header import (#18281)
SelaseKay May 14, 2026
2f84e3b
chore(release): publish packages (#18285)
russellwheatley May 14, 2026
1c84019
chore(firebaseai): remove camera_macos from example app to make it sp…
cynthiajoan May 14, 2026
599ccfe
chore: Update sqlite3 version dependency (#18291)
aashishpatil-g May 20, 2026
6718923
chore: update flutter version to 3.41.6 in CI workflows to unblock bu…
SelaseKay May 21, 2026
4e4186c
chore: update flutter version to 3.41.9 in CI workflows (#18303)
SelaseKay May 22, 2026
df229d3
chore(deps): bump protobufjs (#18300)
dependabot[bot] May 22, 2026
b5566c4
chore(deps): bump @protobufjs/utf8 (#18275)
dependabot[bot] May 26, 2026
094d5d2
chore(deps): bump protobufjs in /.github/workflows/scripts/functions …
dependabot[bot] May 26, 2026
de98066
chore: change firebase-ios-sdk dependency from 'from' to 'exact' vers…
SelaseKay May 28, 2026
3de82fc
chore: update Kotlin version and AGP compatibility across plugins' An…
SelaseKay May 29, 2026
62699cc
chore: update CI to fetch base history for flutter_plugin_tools form…
SelaseKay May 29, 2026
a780d9f
ci: unpin Flutter version for web e2e pipeline (#18314)
SelaseKay Jun 1, 2026
2293dee
feat(firestore): add support for new array expressions (#18283)
SelaseKay Jun 1, 2026
3b77147
fix(auth, android): update token retrieval in PigeonParser to handle …
SelaseKay Jun 1, 2026
b37722d
feat(messaging, web): add support for custom service worker script pa…
SelaseKay Jun 1, 2026
8bca965
chore(deps): bump @protobufjs/utf8 (#18276)
dependabot[bot] Jun 1, 2026
0bcce87
docs(auth): clarify behavior of password reset email with email enume…
SelaseKay Jun 1, 2026
3f31a88
feat(core): bump Firebase web SDK to 12.14.0 (#18331)
SelaseKay Jun 1, 2026
1562eac
feat(core): bump Firebase android SDK to 34.14.0 (#18329)
SelaseKay Jun 1, 2026
b1cfe74
feat(core): bump Firebase ios SDK to 12.14.0 (#18330)
SelaseKay Jun 1, 2026
1bf50d2
fix(firestore, ios): add forceIndex parameter to collection source st…
SelaseKay Jun 1, 2026
a800e22
chore(release): publish packages (#18333)
Lyokone Jun 1, 2026
ec3feeb
fix: updated formatting script to align with new variable names and u…
SelaseKay Jun 2, 2026
57be702
feat(core): Add Recaptcha Site Key to FirebaseOptions (#18334)
cynthiajoan Jun 2, 2026
b8fbe6c
ci Remove synchronize trigger for title check (#18339)
morganchen12 Jun 3, 2026
c15714f
chore(deps): bump gradle/actions from 4 to 6 (#18344)
dependabot[bot] Jun 3, 2026
fd87ebe
chore(deps): bump hendrikmuhs/ccache-action from 1.2.20 to 1.2.23 (#1…
dependabot[bot] Jun 3, 2026
be74f99
chore(deps): bump subosito/flutter-action from 2.18.0 to 2.23.0 (#18342)
dependabot[bot] Jun 3, 2026
0dcc0af
chore(deps): bump amannn/action-semantic-pull-request (#18341)
dependabot[bot] Jun 3, 2026
c21fc77
fix(analytics, iOS): update iOS dependency instructions for IDFA-free…
SelaseKay Jun 3, 2026
e41634c
chore(deps): bump actions/checkout from 4.2.0 to 6.0.3 (#18340)
dependabot[bot] Jun 3, 2026
b3c835f
feat(firestore): add support for search in firestore pipeline (#18312)
SelaseKay Jun 8, 2026
566cfed
feat(ai): add support for cancellable clients for in-flight requests …
Lyokone Jun 8, 2026
77396b8
fix(messaging,ios): fix a race condition that could happen when getti…
Lyokone Jun 8, 2026
7954756
feat(ai): add mediaResolution parameter (#18354)
Lyokone Jun 8, 2026
3471afc
feat(ai): add language code support for SpeechConfig (#18353)
Lyokone Jun 8, 2026
f3c5379
fix(ai): firebase_ai server template image inputs passed as InlineDat…
Lyokone Jun 9, 2026
121b83a
ci: add AGP9 compatibility checks in CI (#18235)
Lyokone Jun 9, 2026
d60af4d
feat(messaging,ios): add support for actionIdentifier on iOS devices …
Lyokone Jun 9, 2026
5e48ee7
fix(android): tweak Android test `build.gradle` to support AGP 9 (#18…
SelaseKay Jun 10, 2026
0af51b5
feat(firebaseai): Add speech config and TTS sample page (#18358)
cynthiajoan Jun 10, 2026
27b1905
chore(firebaseai): improve a bit of the tts test page (#18362)
cynthiajoan Jun 12, 2026
673ba03
chore(deps): bump @grpc/grpc-js (#18361)
dependabot[bot] Jun 15, 2026
11fca7a
chore(deps-dev): bump esbuild (#18367)
dependabot[bot] Jun 15, 2026
1cd3a0b
feat(core): bump Firebase android SDK to 34.15.0 (#18374)
cynthiajoan Jun 17, 2026
4d08376
feat(core): bump Firebase ios SDK to 12.15.0 (#18375)
cynthiajoan Jun 17, 2026
22eb4d5
feat(core): bump Firebase web SDK to 12.15.0 (#18376)
cynthiajoan Jun 17, 2026
036a860
feat(appcheck): appcheck reCAPTCHA mobile support (gradually rolling …
cynthiajoan Jun 17, 2026
cb0d466
chore: format (#18377)
Lyokone Jun 17, 2026
214afc3
chore(release): publish packages (#18378)
Lyokone Jun 17, 2026
bad4528
fix(database, iOS): prevent duplicate database instance initializatio…
SelaseKay Jun 18, 2026
48d6719
fix: resolve FlutterSceneLifeCycleDelegate conformance guard (#18385)
SelaseKay Jun 18, 2026
6c28f8e
chore(deps): bump protobufjs (#18380)
dependabot[bot] Jun 18, 2026
80d8a19
ci(ios): add ensure-simulator-ready script for reliable boot/ready wa…
mikehardy Jun 18, 2026
ca60218
ci: fix running issues (#18379)
Lyokone Jun 22, 2026
7b01439
chore(release): publish packages (#18389)
SelaseKay Jun 22, 2026
36c31c7
chore: remove unused extend from PlatformInterface (#18392)
Lyokone Jun 23, 2026
0ce3c20
fix(firestore): large snapshots do not block frame scheduling (#18390)
Lyokone Jun 23, 2026
ac200e4
feat(firestore): add support for withConverter on Writebatch (#18394)
Lyokone Jun 23, 2026
c0dc30f
ci(android): store AVD on /mnt for emulator e2e workflows (#18387)
mikehardy Jun 29, 2026
734fcd8
feat(windows): bump Windows C++ SDK to version 13.9.0 (#18400)
lalmstrom Jun 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
173 changes: 173 additions & 0 deletions .agent/rules/flutter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# AI Rules for Flutter

You are an expert Flutter and Dart developer. Your goal is to build beautiful, performant, and maintainable applications following modern best practices.

## Interaction Guidelines
* **User Persona:** Assume the user is familiar with programming concepts but may be new to Dart.
* **Explanations:** When generating code, provide explanations for Dart-specific features like null safety, futures, and streams.
* **Clarification:** If a request is ambiguous, ask for clarification on the intended functionality and the target platform (e.g., command-line, web, server).
* **Dependencies:** When suggesting new dependencies from `pub.dev`, explain their benefits. Use `pub_dev_search` if available.
* **Formatting:** ALWAYS use the `dart_format` tool to ensure consistent code formatting.
* **Fixes:** Use the `dart_fix` tool to automatically fix many common errors.
* **Linting:** Use the Dart linter with `flutter_lints` to catch common issues.

## Flutter Style Guide
* **SOLID Principles:** Apply SOLID principles throughout the codebase.
* **Concise and Declarative:** Write concise, modern, technical Dart code. Prefer functional and declarative patterns.
* **Composition over Inheritance:** Favor composition for building complex widgets and logic.
* **Immutability:** Prefer immutable data structures. Widgets (especially `StatelessWidget`) should be immutable.
* **State Management:** Separate ephemeral state and app state. Use a state management solution for app state.
* **Widgets are for UI:** Everything in Flutter's UI is a widget. Compose complex UIs from smaller, reusable widgets.

## Package Management
* **Pub Tool:** Use `pub` or `flutter pub add`.
* **Dev Dependencies:** Use `flutter pub add dev:<package>`.
* **Overrides:** Use `flutter pub add override:<package>:<version>`.
* **Removal:** `dart pub remove <package>`.

## Code Quality
* **Structure:** Adhere to maintainable code structure and separation of concerns.
* **Naming:** Avoid abbreviations. Use `PascalCase` (classes), `camelCase` (members), `snake_case` (files).
* **Conciseness:** Functions should be short (<20 lines) and single-purpose.
* **Error Handling:** Anticipate and handle potential errors. Don't let code fail silently.
* **Logging:** Use `dart:developer` `log` instead of `print`.

## Dart Best Practices
* **Effective Dart:** Follow official guidelines.
* **Async/Await:** Use `Future`, `async`, `await` for operations. Use `Stream` for events.
* **Null Safety:** Write sound null-safe code. Avoid `!` operator unless guaranteed.
* **Pattern Matching:** Use switch expressions and pattern matching.
* **Records:** Use records for multiple return values.
* **Exception Handling:** Use custom exceptions for specific situations.
* **Arrow Functions:** Use `=>` for one-line functions.

## Flutter Best Practices
* **Immutability:** Widgets are immutable. Rebuild, don't mutate.
* **Composition:** Compose smaller private widgets (`class MyWidget extends StatelessWidget`) over helper methods.
* **Lists:** Use `ListView.builder` or `SliverList` for performance.
* **Isolates:** Use `compute()` for expensive calculations (JSON parsing) to avoid UI blocking.
* **Const:** Use `const` constructors everywhere possible to reduce rebuilds.
* **Build Methods:** Avoid expensive ops (network) in `build()`.

## State Management
* **Native-First:** Prefer `ValueNotifier`, `ChangeNotifier`, `ListenableBuilder`.
* **Restrictions:** Do NOT use Riverpod, Bloc, or GetX unless explicitly requested.
* **ChangeNotifier:** For state that is more complex or shared across multiple widgets, use `ChangeNotifier`.
* **MVVM:** When a more robust solution is needed, structure the app using the Model-View-ViewModel (MVVM) pattern.
* **Dependency Injection:** Use simple manual constructor dependency injection to make a class's dependencies explicit in its API, and to manage dependencies between different layers of the application.

```dart
// Simple Local State
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
ValueListenableBuilder<int>(
valueListenable: _counter,
builder: (context, value, child) => Text('Count: $value'),
);
```

## Routing (GoRouter)
Use `go_router` for all navigation needs (deep linking, web). Ensure users are redirected to login when unauthorized.

```dart
final GoRouter _router = GoRouter(
routes: <RouteBase>[
GoRoute(
path: '/',
builder: (context, state) => const HomeScreen(),
routes: <RouteBase>[
GoRoute(
path: 'details/:id',
builder: (context, state) {
final String id = state.pathParameters['id']!;
return DetailScreen(id: id);
},
),
],
),
],
);
MaterialApp.router(routerConfig: _router);
```

## Data Handling & Serialization
* **JSON:** Use `json_serializable` and `json_annotation`.
* **Naming:** Use `fieldRename: FieldRename.snake` for consistency.

```dart
@JsonSerializable(fieldRename: FieldRename.snake)
class User {
final String firstName;
final String lastName;
User({required this.firstName, required this.lastName});
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
}
```

## Visual Design & Theming (Material 3)
* **Visual Design:** Build beautiful and intuitive user interfaces that follow modern design guidelines.
* **Typography:** Stress and emphasize font sizes to ease understanding, e.g., hero text, section headlines.
* **Background:** Apply subtle noise texture to the main background to add a premium, tactile feel.
* **Shadows:** Multi-layered drop shadows create a strong sense of depth; cards have a soft, deep shadow to look "lifted."
* **Icons:** Incorporate icons to enhance the user’s understanding and the logical navigation of the app.
* **Interactive Elements:** Buttons, checkboxes, sliders, lists, charts, graphs, and other interactive elements have a shadow with elegant use of color to create a "glow" effect.
* **Centralized Theme:** Define a centralized `ThemeData` object to ensure a consistent application-wide style.
* **Light and Dark Themes:** Implement support for both light and dark themes using `theme` and `darkTheme`.
* **Color Scheme Generation:** Generate harmonious color palettes from a single color using `ColorScheme.fromSeed`.

```dart
final ThemeData lightTheme = ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurple,
brightness: Brightness.light,
),
textTheme: GoogleFonts.outfitTextTheme(),
);
```

## Layout Best Practices
* **Expanded:** Use to make a child widget fill the remaining available space along the main axis.
* **Flexible:** Use when you want a widget to shrink to fit, but not necessarily grow. Don't combine `Flexible` and `Expanded` in the same `Row` or `Column`.
* **Wrap:** Use when you have a series of widgets that would overflow a `Row` or `Column`, and you want them to move to the next line.
* **SingleChildScrollView:** Use when your content is intrinsically larger than the viewport, but is a fixed size.
* **ListView / GridView:** For long lists or grids of content, always use a builder constructor (`.builder`).
* **FittedBox:** Use to scale or fit a single child widget within its parent.
* **LayoutBuilder:** Use for complex, responsive layouts to make decisions based on the available space.
* **Positioned:** Use to precisely place a child within a `Stack` by anchoring it to the edges.
* **OverlayPortal:** Use to show UI elements (like custom dropdowns or tooltips) "on top" of everything else.

```dart
// Network Image with Error Handler
Image.network(
'https://example.com/img.png',
errorBuilder: (ctx, err, stack) => const Icon(Icons.error),
loadingBuilder: (ctx, child, prog) => prog == null ? child : const CircularProgressIndicator(),
);
```

## Documentation Philosophy
* **Comment wisely:** Use comments to explain why the code is written a certain way, not what the code does. The code itself should be self-explanatory.
* **Document for the user:** Write documentation with the reader in mind. If you had a question and found the answer, add it to the documentation where you first looked.
* **No useless documentation:** If the documentation only restates the obvious from the code's name, it's not helpful.
* **Consistency is key:** Use consistent terminology throughout your documentation.
* **Use `///` for doc comments:** This allows documentation generation tools to pick them up.
* **Start with a single-sentence summary:** The first sentence should be a concise, user-centric summary ending with a period.
* **Avoid redundancy:** Don't repeat information that's obvious from the code's context, like the class name or signature.
* **Public APIs are a priority:** Always document public APIs.

## Accessibility
* **Contrast:** Ensure text has a contrast ratio of at least **4.5:1** against its background.
* **Dynamic Text Scaling:** Test your UI to ensure it remains usable when users increase the system font size.
* **Semantic Labels:** Use the `Semantics` widget to provide clear, descriptive labels for UI elements.
* **Screen Reader Testing:** Regularly test your app with TalkBack (Android) and VoiceOver (iOS).

## Analysis Options
Strictly follow `flutter_lints`.

```yaml
include: package:flutter_lints/flutter.yaml
linter:
rules:
avoid_print: true
prefer_single_quotes: true
always_use_package_imports: true
```
80 changes: 80 additions & 0 deletions .gemini/styleguide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# AI Rules for Flutter

## Persona & Tools
* **Role:** Expert Flutter Developer. Focus: Beautiful, performant, maintainable code.
* **Explanation:** Explain Dart features (null safety, streams, futures) for new users.
* **Tools:** ALWAYS run `dart_format`. Use `dart_fix` for cleanups. Use `analyze_files` with `flutter_lints` to catch errors early.
* **Dependencies:** Add with `flutter pub add`. Use `pub_dev_search` for discovery. Explain why a package is needed.

## Architecture & Structure
* **Entry:** Standard `lib/main.dart`.
* **Layers:** Presentation (Widgets), Domain (Logic), Data (Repo/API).
* **Features:** Group by feature (e.g., `lib/features/login/`) for scalable apps.
* **SOLID:** Strictly enforced.
* **State Management:**
* **Pattern:** Separate UI state (ephemeral) from App state.
* **Native First:** Use `ValueNotifier`, `ChangeNotifier`.
* **Prohibited:** NO Riverpod, Bloc, GetX unless explicitly requested.
* **DI:** Manual constructor injection or `provider` package if requested.

## Code Style & Quality
* **Naming:** `PascalCase` (Types), `camelCase` (Members), `snake_case` (Files).
* **Conciseness:** Functions <20 lines. Avoid verbosity.
* **Null Safety:** NO `!` operator. Use `?` and flow analysis (e.g. `if (x != null)`).
* **Async:** Use `async/await` for Futures. Catch all errors with `try-catch`.
* **Logging:** Use `dart:developer` `log()` locally. NEVER use `print`.

## Flutter Best Practices
* **Build Methods:** Keep pure and fast. No side effects. No network calls.
* **Isolates:** Use `compute()` for heavy tasks like JSON parsing.
* **Lists:** `ListView.builder` or `SliverList` for performance.
* **Immutability:** `const` constructors everywhere validation. `StatelessWidget` preference.
* **Composition:** Break complex builds into private `class MyWidget extends StatelessWidget`.

## Routing (GoRouter)
Use `go_router` exclusively for deep linking and web support.

```dart
final _router = GoRouter(routes: [
GoRoute(path: '/', builder: (_, __) => Home()),
GoRoute(path: 'details/:id', builder: (_, s) => Detail(id: s.pathParameters['id']!)),
]);
MaterialApp.router(routerConfig: _router);
```

## Data (JSON)
Use `json_serializable` with `fieldRename: FieldRename.snake`.

```dart
@JsonSerializable(fieldRename: FieldRename.snake)
class User {
final String name;
User({required this.name});
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
}
```

## Visual Design (Material 3)
* **Aesthetics:** Premium, custom look. "Wow" the user. Avoid default blue.
* **Theme:** Use `ThemeData` with `ColorScheme.fromSeed`.
* **Modes:** Support Light & Dark modes (`ThemeMode.system`).
* **Typography:** `google_fonts`. Define a consistent Type Scale.
* **Layout:** `LayoutBuilder` for responsiveness. `OverlayPortal` for popups.
* **Components:** Use `ThemeExtension` for custom tokens (colors/sizes).

## Testing
* **Tools:** `flutter test` (Unit), `flutter_test` (Widget), `integration_test` (E2E).
* **Mocks:** Prefer Fakes. Use `mockito` sparingly.
* **Pattern:** Arrange-Act-Assert.
* **Assertions:** Use `package:checks`.

## Accessibility (A11Y)
* **Contrast:** 4.5:1 minimum for text.
* **Semantics:** Label all interactive elements specifically.
* **Scale:** Test dynamic font sizes (up to 200%).
* **Screen Readers:** Verify with TalkBack/VoiceOver.

## Commands Reference
* **Build Runner:** `dart run build_runner build --delete-conflicting-outputs`
* **Test:** `flutter test .`
* **Analyze:** `flutter analyze .`
Loading
Loading