agentleFS
ArenukvernArenukvern/mcp_flutter/.cursor/rules/flutter_ui_dev.mdc

mcp_flutter / rules

Cursor rule385 starsChanged 5 months agoMITView on GitHub

when creating or modifing flutter widgets

The file

We split this flutter_ui_dev.mdc into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prefer fewer, more cohesive widgets over many tiny widgets

    line 18
  2. Distinctive:

    Use section comments to delineate logical UI parts:

    line 31
  3. Distinctive:

    Prefer fewer widgets for simpler screens

    line 53
  4. Distinctive:

    Use const constructors aggressively

    line 54
  5. Distinctive:

    Document the "why" more than the "what" when using comments

    line 59

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
flutter_ui_dev.mdc
---
description: when creating or modifing flutter widgets
alwaysApply: false
---

# Flutter widgets and concepts:

- Dart 3.11 syntax for null safety, pattern matching, and more
- Appropriate use of StatelessWidget, or Stateful widgets (NO riverpod)
- Custom reusable widgets (use ui_kit) instead of methods
- Cupertino or Material Design as appropriate
- Proper error handling and async/await for asynchronous operations
- flutter_animate for animations

# Widget Composition Guidelines:

1. **Appropriate Widget Granularity**:
   - Prefer fewer, more cohesive widgets over many tiny widgets
   - Extract new widget classes only when they are:
   - Reused in multiple places
   - Complex enough to warrant separation (>10 lines)
   - Logically independent with clear boundaries
   - For simpler UIs, use a single widget with well-commented sections

2. **Code Organization Hierarchy**:
   - First preference: Use comments to separate logical sections within a widget
   - Second preference: Extract logical methods for complex sections (>10 && <30 lines)
   - Last preference: Create new widget classes

3. **Comment-Based Structure**:
   - Use section comments to delineate logical UI parts:

   ```dart
   // Header section
   Column(
      children: [
         // Title
         Text('Title'),
         // Subtitle
         Text('Subtitle'),
      ],
   ),
   ```

4. **Refactoring Decision Tree**:
   - Is the component reused? → Extract widget
   - Is the component >50 lines? → Consider extraction
   - Is the component logically independent? → Consider extraction
   - Otherwise → Keep in parent with comments

5. **Performance Considerations**:
   - Be mindful that each widget adds overhead
   - Prefer fewer widgets for simpler screens
   - Use const constructors aggressively

6. **Documentation Balance**:
   - For single-class approaches, use inline comments instead of class-level docs
   - Reserve detailed documentation for public APIs and complex widgets
   - Document the "why" more than the "what" when using comments

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.