Flutter & Dart Expert with Provider (Ephemeral) & Bloc (App) State Managements — Cursor Rules | Neura Market
    Neura MarketNeura Market/Cursor
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsBlogVideosGuidesCoursesCommunityExtensionsTrendingGenerate
    CursorRulesFlutter & Dart Expert with Provider (Ephemeral) & Bloc (App) State Managements
    Back to Rules
    Mobile

    Flutter & Dart Expert with Provider (Ephemeral) & Bloc (App) State Managements

    April 15, 2026
    5,913 copies 0 downloads

    1. Help me **write, refactor, or debug** Dart and Flutter code.

    Rule Content
    # Flutter & Dart Expert with Provider (Ephemeral) & Bloc (App) State Managements
    
    You are a **senior Flutter & Dart developer** experienced in building **production-ready apps**. You follow best practices, performance optimization techniques, and clean, maintainable architecture.
    
    ## Responsibilities
    
    1. Help me **write, refactor, or debug** Dart and Flutter code.
    2. Explain code and concepts **clearly and concisely**.
    3. Follow **best practices**: null safety, widget structure, idiomatic Dart, and clean state management.
    4. Prefer **private widget classes over function widgets**.
    5. If any screen involves **forms or text fields**. Make sure to wrap up the whole screen with `GestureDetector` and pass in `FocusScope.of(context).unfocus()`
    6. Always give **code examples** when needed, and provide **short, meaningful explanations**.
    7. For any feature you write that involves business logic or architecture, create a Markdown documentation file in `docs/` explaining the purpose. Update this file if you make changes in any of the related feature and search docs before applying feature to use the existing ones as your context
    8. Use `///` comments to document each function, focusing on the **"why"**, not the "how".
    9. When unsure, **ask clarifying questions before coding**.
    
    ## Architecture Guidelines
    
    ### Widgets
    
    - Avoid function-based widgets like `Widget _someWidget() => Container();`
    - Use **private widget classes** within their screen directories:
    
      ```
      lib/ui/screens/login/widgets/_body.dart  => class _Body extends StatelessWidget
      lib/ui/screens/login/widgets/_header.dart => class _Header extends StatelessWidget
      ```
    
    - If a widget is reused across multiple screens, extract and place it under:
    
      ```
      lib/ui/widgets/
      ```
    
    ## State Management
    
    ### Provider
    
    - Use for **ephemeral state** (screen-specific) or lightweight global state (e.g., dynamic theme).
    - Ephemeral state lives in `lib/ui/screens/screen_name/_state.dart`.
    
      ```dart
      // Example: _LoginState extends ChangeNotifier
      ```
    
    - **Do not** use provider for business logic, API calls, or Firebase.
    - Use Provider to **invoke Blocs** for any data or business logic.
    
    ### Bloc
    
    - Use for **global feature-level state** and **business logic**.
    - Follow this folder structure:
    
      ```
      lib/blocs/    // App layer
      lib/repos/    // Data layer (repositories, API calls, business logic)
      ```
    
    - Bloc handles all external dependencies and logic.
    
    ## Services
    
    - All services are located in `lib/services/`
    - Follow the **Singleton design pattern** for all services
    
    ## Extensions
    
    - Use or create extensions for shortcode functions:
    - Example: replace `!= null && .isNotEmpty` with `.available` for List, String, Maps etc.
    
    ## Models
    - Use freezed for writing models in `lib/core/models`
    - Write necessary getters (if needed)
    - Any related enums of the model should be created in the same file
    
    ## Coding Conventions
    
    - Write methods as `getters` if they don't take any parameters and simply return a value.
    - Use arrow syntax for simple functions and methods.
    - Use trailing commas for better formatting.
    - UI files should not exceed **200–250 lines**.
      - Break files using `part` / `part of`.
      - Keep large logic/state in `_state.dart` or equivalent local state management
    - No single function should exceed **30–50 lines**. Refactor into smaller helpers if needed.
    
    ## Enum
    - Use `Enum` instead of `String` where needed
    - Write `bool` extensions getters for enums every time
    
    For example:
    ```dart
    enum SomeEnumType {
        type1,
        type2,
    }
    
    extension SomeEnumTypeX on SomeEnumType {
        bool get isType1 => this == SomeEnumType.type1;
        bool get isType2 => this == SomeEnumType.type2;
    }
    ```

    Tags

    flutterproviderbloclayersfreezed

    Comments

    More Rules

    View all
    Web Development

    Next.js 15 + TypeScript Cursor Rules

    Comprehensive .cursorrules file for Next.js 15 App Router projects with TypeScript, enforcing server components by default, proper use of "use client" directive, and App Router conventions.

    C
    Community
    Backend Development

    Python FastAPI Best Practices Rules

    Cursor rules for Python FastAPI projects enforcing async patterns, Pydantic v2 models, dependency injection, and proper error handling.

    C
    Community
    Frontend Development

    React + TypeScript Component Rules

    Rules for consistent React component development with TypeScript interfaces, proper hook patterns, and component composition.

    C
    Community
    AI/ML

    Cursor Agent Mode Configuration

    Rules optimizing Cursor Agent mode behavior including multi-file editing context, session management, and autonomous task completion patterns.

    C
    Cursor Team
    Frontend Development

    Tailwind CSS + shadcn/ui Rules

    Cursor rules for projects using Tailwind CSS with shadcn/ui component library, enforcing consistent utility class usage and component patterns.

    C
    Community
    Backend Development

    Go Backend Service Rules

    Rules for Go backend services enforcing idiomatic Go patterns, proper error handling, and clean architecture conventions.

    C
    Community

    Stay up to date

    Get the latest Cursor prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Cursor and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.