Cursor Flutter 编码规范

Model: qwen-max | ¥0.15/call
AI工具GPT-4.1智能助手CursorFlutter

Cursor Flutter 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 flu,适用于各类文档与内容的智能化处理。

Calls: 1

Skill Documentation

Cursor Flutter 编码规范

摘要

Cursor Flutter 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 flu,适用于各类文档与内容的智能化处理。

**文件来源:** PatrickJS/awesome-cursorrules → `rules/flutter-development-guidelines-cursorrules-prompt-file.mdc`

**原仓库:** https://github.com/PatrickJS/awesome-cursorrules

**评分:** ⭐ 仓库 40k stars (社区最权威 Cursor rules 合集)

这个 skill 是干什么的?

把 `flutter-development-guidelines-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。

> Cursor rules for Flutter development with MVVM architecture, Riverpod state management, Material widgets, and Dart style guidelines.

🤖 Agent 使用说明

👤 用户需要做什么?

适用场景

原始规则内容

globs: **/*.dart
alwaysApply: false
---
### Code style and structure
- Write concise and efficient source code.
- Strive for source code that is easy to read and maintain, and provide accurate examples.
- Avoid duplication of code: modularise widgets and functions into reusable components.
- Use descriptive variable names: use names with auxiliary verbs such as isLoading, hasError.

### Directory structure under /lib.
- /lib/models/: data models and type definitions (Models)
- /lib/viewmodels/: state management and business logic (ViewModel)
- /lib/views/widgets/: reusable widgets (View)
- /lib/views/screens/: per-screen widgets (View)
- /lib/services/: service classes for API calls and data access
- /lib/utils/: helper functions and constants

### Naming conventions
- Directories and files: use snakeCase (e.g. auth_wizard.dart).
- UpperCamelCase: use for class names/enumerations/typedefs/type parameters, etc.
- LowerCamelCase: used for variables/functions/class members (properties, methods), etc.
- lowercase_with_underscores (snakeCase): for files/directories/packages/libraries, etc.

### Import.
- Place imports starting with dart: first (use lowercase_with_underscores for the import prefix).
- Next, import third-party packages (package:).
- Finally, import relative paths and files in the project.

### Using Dart.
- Take advantage of type safety: use static typing in all code and utilise type inference wherever possible.

### UI and styling.
- Use Material widgets.
- Unify theming: use ThemeData to apply consistent styles.

### Performance optimisation.
- Prefer StatelessWidget when state is not required.
- Make use of const constructors: if widgets are immutable, use const to optimise builds.

### State management.
- Use riverpod to implement efficient state management.
- Manage state within the ViewModel and link it to the View.

### Software architecture
Use MVVM (Model View ViewModel).

### Key rules.
- To improve code readability, lines should not exceed 80 characters in length.
- Use braces {} for all flow control structures (if, for, while, etc.).
- Use comment-outs proactively to help understand and maintain code.
- Use single quotes, avoid the use of double quotes and use consistent string literals to improve readability.

数据来源

联系方式

有问题或建议,在本 skill 下留言。

FAQ

这个 skill 是干什么的?

把 `flutter-development-guidelines-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。

> Cursor rules for Flutter development with MVVM architecture, Riverpod state management, Material widgets, and Dart style guidelines.

👤 用户需要做什么?
  • [ ] 知道这条规则适合用在什么场景(参考下面"适用场景")
  • [ ] 把规则原文内容应用到 IDE 项目的 `.cursor/rules/` 目录(直接复制 .mdc 文件)
  • [ ] 调本 skill 时说清楚你的代码任务(语言/框架/目标)
  • [ ] 输出后人工 review 风格是否符合预期