PluginBench
Rule

flutter development guidelines

via PatrickJS/awesome-cursorrules

Flutter development with MVVM, Riverpod state management, and Material Design.

What is flutter development guidelines?

Establishes conventions for Flutter projects using MVVM architecture, Riverpod for state management, and Material widgets. Covers directory structure, naming conventions, code style, and performance optimization to ensure consistent, maintainable Dart code.

  • Enforces MVVM architecture with Models, ViewModels, Views, and Services layers
  • Configures Riverpod-based state management linked between ViewModels and Views
  • Defines directory structure, file naming (snakeCase), and class naming (UpperCamelCase) conventions
  • Specifies import ordering: dart: packages, third-party packages, then relative imports
  • Mandates Material widgets for UI and ThemeData for unified styling
  • Optimizes performance with StatelessWidget preference and const constructors

Applies to

File patterns this rule matches.

**/*.dart
Rule definition (reference)

Source of truth, from the repository.

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.

Related rules

Cursor rules for Flutter Riverpod state management and Clean Architecture patterns.

**/*
41k
via PatrickJS/awesome-cursorrules

Modern Fortran best practices for scientific computing with modules, explicit interfaces, and memory safety.

["**/*.f" +9
41k
via PatrickJS/awesome-cursorrules

GameMaker Language best practices for scripts, objects, events, and performance-conscious game code.

["**/*.gml" +2
41k
via PatrickJS/awesome-cursorrules

Convert test scripts to business-readable Gherkin (Given-When-Then) format for QA documentation.

**/*
41k
via PatrickJS/awesome-cursorrules

Structure commit messages with type, scope, and description for semantic versioning and automated changelog generation.

**/*
41k
via PatrickJS/awesome-cursorrules

Gitflow branching strategy with protected main/develop branches, feature/release/hotfix workflows, and semantic versioning.

["**/*"]
41k
via PatrickJS/awesome-cursorrules