

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# Flutter with Dart — Cursor Rules23You are an expert Flutter developer building cross-platform mobile and web applications with Dart, following Flutter best practices and Material Design 3.45## Code Style67- Use Dart 3+ features: records, patterns, sealed classes, class modifiers (`final`, `base`, `interface`).8- Follow Effective Dart guidelines. Use `dart_style` (dartfmt) for formatting.9- Use `lowerCamelCase` for variables, functions, and parameters. `UpperCamelCase` for classes, enums, typedefs, and extensions. `lowercase_with_underscores` for file names and libraries.10- Prefer `final` over `var` for variables that don't change after initialization.11- Use `const` constructors wherever possible — it improves widget rebuild performance.12- Use type annotations for function parameters, return types, and public API. Let Dart infer types for local variables.13- Use `///` doc comments on all public classes, methods, and properties. Start with a single-sentence summary.14- Use trailing commas on all parameter lists and collection literals for consistent formatting.15- Prefer `String interpolation $variable` over concatenation.16- Run `dart analyze` with no issues before committing. Enable `strict-casts` and `strict-raw-types`.1718## Widget Architecture1920- Prefer composition over inheritance. Build complex UIs by combining small, focused widgets.21- Keep the `build()` method concise. Extract sub-widgets into private methods or separate widget classes.22- Use `StatelessWidget` by default. Only use `StatefulWidget` when the widget has mutable state.23- Split large widgets into smaller widgets rather than using many helper methods. Separate widget classes optimize rebuild performance.24- Use `const` constructors for widgets that don't depend on runtime data.25- Never put business logic in widgets. Widgets are for UI only.26- Use `Key` parameters when the widget tree can change (lists, conditional rendering).2728## State Management2930- Use Riverpod as the primary state management solution. Prefer Riverpod over Provider, BLoC, or GetX for new projects.31- Define providers outside of widgets. Use `ref.watch()` in `build()` for reactive UI, `ref.read()` for one-time reads in callbacks.32- Use `StateNotifierProvider` or `NotifierProvider` for complex state logic.33- Use `FutureProvider` for async data fetching. Use `StreamProvider` for real-time data.34- Keep state classes immutable. Use `copyWith()` for state updates.35- Use `AsyncValue` pattern for loading/error/data states. Handle all three in the UI.36- Scope providers to features. Create a `providers/` directory per feature module.3738## Navigation3940- Use GoRouter for declarative routing. Define routes in a central `router.dart` file.41- Use typed route parameters. Define route path constants to avoid magic strings.42- Use `context.go()` for navigation, `context.push()` for adding to the stack.43- Use shell routes for persistent bottom navigation or side navigation.44- Handle deep links by defining route patterns that match the expected URL structure.45- Use redirect guards for authentication: redirect unauthenticated users to login.46- Use `StatefulShellRoute` for tabs that preserve state across tab switches.4748## Layout and Design4950- Follow Material Design 3 guidelines. Use `MaterialApp` with `useMaterial3: true`.51- Use `ThemeData` with `ColorScheme.fromSeed()` for consistent theming.52- Use `LayoutBuilder` and `MediaQuery` for responsive layouts. Define breakpoints for mobile, tablet, desktop.53- Use `Flex`, `Column`, `Row`, `Expanded`, `Flexible` for layout. Avoid hardcoded sizes.54- Use `SizedBox` for spacing between widgets. Avoid `Padding` when `SizedBox` suffices.55- Use `SafeArea` to avoid system UI overlap (notches, status bar, navigation bar).56- Use `Scaffold` as the root of each screen with `AppBar`, `body`, `bottomNavigationBar`, and `floatingActionButton`.57- Extract theme-specific values from `Theme.of(context)`. Never hardcode colors, font sizes, or spacing.5859## Networking6061- Use `dio` for HTTP networking with interceptors for auth, logging, and error handling.62- Create a centralized API client class that configures base URL, headers, and interceptors.63- Use data classes for API responses. Parse JSON into typed Dart objects.64- Use `freezed` for immutable data classes with `fromJson`/`toJson` generated by `json_serializable`.65- Handle network errors gracefully: timeout, no connection, server errors. Show user-friendly messages.66- Use `CancelToken` to cancel requests when widgets are disposed.67- Cache API responses with an appropriate strategy (stale-while-revalidate, cache-first).6869## Error Handling7071- Use `sealed class` for result types: `sealed class Result<T> { Success(T data); Failure(AppException error); }`.72- Define domain-specific exception classes. Map API errors to domain exceptions in the repository layer.73- Use `try/catch` with specific exception types. Never use bare `catch`.74- Show user-friendly error messages with `SnackBar` or inline error widgets. Never show raw exception messages.75- Use `ErrorWidget.builder` for custom error widgets during development.76- Log errors with a logging framework. Include stack traces for unexpected errors.77- Use `FlutterError.onError` to capture widget build errors.7879## Testing8081- Use `flutter_test` for widget tests, `test` for unit tests, `integration_test` for integration tests.82- Write unit tests for business logic, state management, and data models.83- Write widget tests for UI components. Use `find.byType`, `find.text`, `find.byKey` for element queries.84- Use `tester.pumpWidget()` to render widgets, `tester.tap()` and `tester.enterText()` for interactions.85- Mock dependencies with `mocktail` or `mockito`. Create fakes for complex dependencies.86- Test all states: loading, data, error, empty.87- Achieve high test coverage on business logic. Visual components need fewer tests.88- Place tests in `test/` mirroring the `lib/` structure.8990## File Structure9192```93lib/94 main.dart — Entry point, app setup95 app.dart — MaterialApp, router, theme configuration96 core/97 theme/98 app_theme.dart — ThemeData configuration99 colors.dart — Color constants100 network/101 api_client.dart — Dio client setup102 interceptors.dart — Auth, logging interceptors103 utils/104 extensions.dart — Dart extension methods105 validators.dart — Input validation106 errors/107 app_exception.dart — Exception classes108 error_handler.dart — Global error handling109 features/110 auth/111 data/112 auth_repository.dart113 models/user_model.dart114 presentation/115 screens/login_screen.dart116 widgets/login_form.dart117 providers/auth_provider.dart118 home/119 data/120 presentation/121 screens/home_screen.dart122 widgets/123 providers/124 shared/125 widgets/ — Reusable UI components126 app_button.dart127 loading_indicator.dart128 error_view.dart129 providers/ — App-wide providers130 router/131 app_router.dart — GoRouter configuration132 routes.dart — Route constants133test/134 features/135 auth/136 auth_repository_test.dart137 login_screen_test.dart138integration_test/139 app_test.dart140```141142## Performance143144- Use `const` constructors aggressively. Every `const` widget avoids unnecessary rebuilds.145- Use `ListView.builder` for long lists (not `ListView` with `children`). This builds items lazily.146- Use `RepaintBoundary` to isolate frequently updated widgets from the rest of the tree.147- Profile with Flutter DevTools. Check for jank, excessive rebuilds, and memory leaks.148- Use `compute()` for expensive computations to run them on a separate isolate.149- Optimize images: use appropriate resolution, cache network images with `cached_network_image`.150- Minimize widget tree depth. Flatter trees rebuild faster.151- Use `AutomaticKeepAliveClientMixin` for tab views that should preserve state.152153## Security154155- Store sensitive data (tokens, keys) with `flutter_secure_storage`. Never use SharedPreferences for secrets.156- Use HTTPS for all network requests. Pin certificates in production if handling sensitive data.157- Validate all user input on both client and server.158- Obfuscate Dart code in release builds: `flutter build --obfuscate --split-debug-info`.159- Never hardcode API keys or secrets in source code. Use `--dart-define` for build-time configuration.160- Sanitize data before displaying user-generated content.161
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| survivorforge/cursor-rulesrules/ai-ml-python/.cursorrules · 17 | .cursorrules | teststylearchdeployment+2 | 81/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/api-microservices/.cursorrules · 17 | .cursorrules | buildteststylearch+5 | 92/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/database-sql/.cursorrules · 17 | .cursorrules | styletypessecuritydatabase+3 | 65/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/devops-docker/.cursorrules · 17 | .cursorrules | setupbuildteststyle+4 | 93/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/devops-infrastructure/.cursorrules · 17 | .cursorrules | buildteststylesecurity+3 | 93/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/django-rest/.cursorrules · 17 | .cursorrules | buildteststylearch+5 | 84/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/docker-devops/.cursorrules · 17 | .cursorrules | setupteststylearch+6 | 85/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/go-gin/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+5 | 84/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/langchain-ai/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+4 | 84/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/mobile-react-native/.cursorrules · 17 | .cursorrules | teststylearchtypes+7 | 89/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nextjs-14-app-router/.cursorrules · 17 | .cursorrules | teststyletypestesting-strategy+3 | 71/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nextjs-app-router/.cursorrules · 17 | .cursorrules | teststylearchtypes+5 | 81/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nextjs-typescript/.cursorrules · 17 | .cursorrules | teststylearchtypes+5 | 81/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nextjs/.cursorrules · 17 | .cursorrules | teststylearchtypes+5 | 81/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nodejs-express-typescript/.cursorrules · 17 | .cursorrules | setupteststylearch+7 | 81/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/nodejs-express/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+7 | 92/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/performance-optimization/.cursorrules · 17 | .cursorrules | styledatabaseapiperformance+2 | 65/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/python-django/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+6 | 99/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/python-fastapi/.cursorrules · 17 | .cursorrules | testlint-formatstylearch+6 | 99/100 | 13 days ago | |
| survivorforge/cursor-rulesrules/python-modern/.cursorrules · 17 | .cursorrules | testlint-formatstyletypes+3 | 88/100 | 13 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/survivorforge-cursor-rules-rules-flutter-dart-cursorrules)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.