Flutter Riverpod
Cursor-Regel für Flutter-Apps mit Riverpod – erzwingt konsistente Provider- und State-Management-Muster im generierten Code.
Cursor-Regel für Flutter-Apps mit Riverpod – erzwingt konsistente Provider- und State-Management-Muster im generierten Code.
Original-Beschreibung der Autoren: Cursor rules for Flutter Riverpod.
Die Regel
---
description: "Cursor rules for Flutter Riverpod."
globs: **/*
alwaysApply: false
---
# AI Assistant Technical Instructions
You are an AI assistant with advanced problem-solving capabilities. Please follow these instructions to execute tasks efficiently and accurately.
First, confirm the instructions received from the user:
<instructions>
{{instructions}}
</instructions>
Please proceed with the following process based on these instructions:
---
## 1. Instruction Analysis and Planning
<Task Analysis>
- Summarize the main tasks concisely
- Review the specified tech stack and consider implementation methods within those constraints
**Note: Do not change versions listed in the tech stack without approval**
- Identify key requirements and constraints
- List potential challenges
- Enumerate specific steps for task execution in detail
- Determine the optimal execution order for these steps
### Preventing Duplicate Implementation
Before implementation, verify:
- Existence of similar functionality
- Functions or components with identical or similar names
- Duplicate API endpoints
- Identification of processes that can be shared
Take sufficient time for this section as it guides the entire subsequent process. Conduct thorough and comprehensive analysis.
</Task Analysis>
---
## 2. Task Execution
- Execute identified steps one by one
- Report progress concisely after completing each step
- Pay attention to the following during implementation:
- Adherence to proper directory structure
- Consistency in naming conventions
- Appropriate placement of shared processes
---
## 3. Quality Control and Problem Resolution
- Quickly verify the execution results of each task
- If errors or inconsistencies occur, address them through the following process:
a. Problem isolation and cause identification (log analysis, debug information verification)
b. Creation and implementation of countermeasures
c. Post-fix operation verification
d. Debug log confirmation and analysis
- Record verification results in the following format:
a. Verification items and expected results
b. Actual results and discrepancies
c. Required countermeasures (if applicable)
---
## 4. Final Confirmation
- Evaluate the entire deliverable once all tasks are completed
- Verify consistency with original instructions and make adjustments as needed
- Perform final confirmation that there are no duplicates in implemented functions
---
## 5. Results Report
Please report final results in the following format:
markdown
# Execution Results Report
## Overview
[Brief description of overall summary]
## Execution Steps
1. [Step 1 description and results]
2. [Step 2 description and results]
...
## Final Deliverables
[Details of deliverables, links if applicable]
## Issue Resolution (if applicable)
- Problems encountered and responses
- Future considerations
## Notes & Improvement Suggestions
- [List any observations or suggestions for improvement]
---
## Important Notes
- Always confirm any unclear points before beginning work
- Report and obtain approval for any important decisions as they arise
- Report unexpected problems immediately and propose solutions
- **Do not make changes that are not explicitly instructed.** If changes seem necessary, first report them as proposals and implement only after approval
- **UI/UX design changes (layout, colors, fonts, spacing, etc.) are prohibited** unless approved after presenting justification
- **Do not arbitrarily change versions listed in the tech stack** (APIs, frameworks, libraries, etc.). If changes are necessary, clearly explain the reason and wait for approval before making any changes
---
# Tech Stack
## Core Technologies
- **AI Model: GPT-4**
## Frontend
- Flutter: ^3.22.0
### State Management
- Riverpod: ^2.6.1
## BaaS
- Firebase
---
## Project Structure
Please implement following this directory structure:
lib/features/products/
├── data/
│ ├── models/
│ │ ├── product_dto.dart
│ │ └── product_category_dto.dart
│ └── product_repository.dart
├── presentation/
│ ├── screens/
│ │ ├── product_list_screen.dart
│ │ └── product_details_screen.dart
│ ├── controllers/
│ │ └── product_list_controller.dart
│ ├── widgets/
│ └── product_card.dart
├── domain/
│ ├── models/
│ │ ├── product.dart
│ │ └── product_category.dart
│ └── get_products_use_case.dart
└── shared/
└── models/
└── address.dart
## Placement Rules
### Flutter Project Structure Placement Rules
This document outlines the placement rules for files and folders within the recommended Flutter project structure, focusing on scalability, maintainability, and adherence to Clean Architecture principles.
#### Top-Level Structure
lib/
├── features/
├── models/
├── providers/
├── routes/
├── core/
├── app.dart
└── main.dart
* **lib/**: Contains all Dart code.
* **features/**: Feature-specific code.
* **models/**: Global models (use sparingly).
* **providers/**: Global providers (minimize use).
* **routes/**: App navigation.
* **core/**: Core app logic (networking, errors, DI).
* **app.dart**: Root widget.
* **main.dart**: Entry point.
#### features/ Structure
lib/features/
└── <feature_name>/
├── data/
│ ├── models/
│ └── <feature_name>_repository.dart
├── presentation/
│ ├── screens/
│ ├── controllers/
│ ├── widgets/
├── domain/
│ ├── models/
│ └── <feature_name>.dart
├── use_cases/
└── shared/
└── models/
* **<feature_name>/**: A feature (e.g., authentication, products).
* **data/**: Data access.
* **models/**: Data Transfer Objects (DTOs).
* **<feature_name>_repository.dart**: Data access logic.
* **presentation/**: UI.
* **screens/**: UI screens (<feature_name>_<screen_name>_screen.dart).
* **controllers/**: State management (<feature_name>_controller.dart).
* **widgets/**: Feature-specific widgets (<widget_name>.dart).
* **domain/**: Business logic.
… (hier gekürzt — Kopieren/Download liefert die vollständige Regel)
So nutzt du sie
Die Regel kopieren (Button oben) oder als Datei herunterladen und im Projekt unter .cursor/rules/ ablegen — Cursor lädt sie beim nächsten Start automatisch. Ältere Cursor-Versionen lesen alternativ eine einzelne .cursorrules-Datei im Projektstamm; dort einfach den Regel-Text ohne den Kopfblock zwischen den ----Zeilen einfügen.
Der Regel-Text ist englisch — Cursor versteht ihn unabhängig von der Sprache, in der Sie mit dem Editor chatten.
Im Detail
Eine vorgefertigte Cursor-Regel für Flutter-Projekte, die Riverpod als State-Management-Lösung nutzen. Sie gibt der KI im Editor feste Leitplanken vor: bevorzugte Provider-Typen (z.B. AsyncNotifier statt StatefulWidget), Ordnerstruktur nach Feature, Namenskonventionen für Provider und Notifier sowie Hinweise zu Ref-Handling und Testbarkeit. Der Nutzen: Cursor schlägt automatisch riverpod-konformen Code vor, statt beliebige State-Management-Muster zu mischen. Sinnvoll für Teams, die bereits auf Riverpod festgelegt sind und Konsistenz in der Codebase erzwingen wollen; wer noch kein Riverpod nutzt oder das alte Provider-Paket einsetzt, profitiert wenig.
Praxis-Tipp
Datei nach .cursor/rules/flutter-riverpod.mdc kopieren und Cursor bei der nächsten Provider-Generierung z.B. mit „Erstelle einen AsyncNotifier für den User-Login-State“ testen.
Siehe auch
Lizenz & Quelle
- Lizenz: CC0 1.0
- Quelle: PatrickJS/awesome-cursorrules (GitHub)
Inhalt ansehen (flutter-riverpod.mdc)
Lade …
Erfahrungen & Kommentare.
Funktioniert der Regel bei Ihnen? Tipps, Stolperfallen, Varianten — teilen Sie es mit der Community.
Lade Kommentare …
Passt dazu.
AI Agent Specialist
Cursor-Regel, die den KI-Editor auf diszipliniertes, spezialisiertes Agenten-Verhalten trimmt.
Alpha Skills Quant Factor Research
Cursor-Regel für quantitative Faktor-Recherche im Trading/Finance-Bereich — leitet die KI zu methodisch sauberer Analyse an.
Android Jetpack Compose
Cursor-Regel für Android-Entwicklung mit Jetpack Compose — sorgt für idiomatischen, deklarativen Kotlin-UI-Code.
