dart-effective-style
Styling Dart Code
Contents
Naming Conventions
Apply the following naming conventions strictly to maintain consistency across the Dart ecosystem.
- Types: Name classes, enum types, typedefs, extensions, and type parameters using
UpperCamelCase. - Variables & Members: Name class members, top-level definitions, variables, parameters, and named parameters using
lowerCamelCase. - Constants: Prefer
lowerCamelCasefor constant variables, including enum values.- Conditional: If editing existing code that uses
SCREAMING_CAPSor working with generated code (e.g., protobufs), maintain consistency with the existing style.
- Conditional: If editing existing code that uses
- Files & Directories: Name packages, directories, and source files using
lowercase_with_underscores. - Import Prefixes: Name import prefixes using
lowercase_with_underscores. - Acronyms: Capitalize acronyms and abbreviations longer than two letters like regular words (e.g.,
Http,Uri). Keep two-letter acronyms fully capitalized (e.g.,ID,UI). If an abbreviation begins alowerCamelCaseidentifier, make it entirely lowercase (e.g.,httpConnection). - Privacy: Use a leading underscore
_for members and top-level declarations to indicate library privacy. Do not use leading underscores for local variables, parameters, local functions, or library prefixes.
More from dart-lang/skills
dart-add-unit-test
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.
2.0Kdart-fix-runtime-errors
Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.
2.0Kdart-run-static-analysis
Execute `dart analyze` to identify warnings and errors, and use `dart fix --apply` to automatically resolve mechanical lint issues. Use during development to ensure code quality and before committing changes.
2.0Kdart-use-pattern-matching
Use switch expressions and pattern matching where appropriate
2.0Kdart-resolve-package-conflicts
Workflow for fixing package version conflicts. Use this when `pub get` fails due to incompatible package versions.
2.0Kdart-collect-coverage
Collect coverage using the coverage packge and create an LCOV report
2.0K