-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlutter-CodeStyle.mdc
More file actions
61 lines (48 loc) · 2.59 KB
/
Flutter-CodeStyle.mdc
File metadata and controls
61 lines (48 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
description: Best practices for developing Flutter applications.
globs: *.dart
---
# Code
## Grouping and Sorting
- When generating code, group members by type, then sort alphabetically.
- When grouping members by type, use the following groups IN THIS ORDER:
- Private Constants
- Public Constants
- Private Variables
- Private Constructors
- Public Constructors
- Private Methods
- Public Methods
- Private Properties
- Public Properties
- Private Events
- Public Events
## Nomenclature
- Consider variables that are not private to be "Public Properties".
- Consider variables that start with 'on' and are related to callbacks as "Events".
- Consider properties that start with 'on' and are related to callbacks as "Events".
## Regions
- Always surround code groups with a matching named region.
- Regions should start with // #region \[GroupName\], for example: // #region \[Public Methods\]
- Regions should end with // #endregion \[GroupName\], for example: // #endregion \[Public Methods\]
- // #region \[GroupName\] statements should be followed by one blank line before code begins.
- // #endregion \[GroupName\] statements should be preceded by one blank line.
- When asked to create regions, always use the group names identified in [Grouping and Sorting](mdc:#grouping-and-sorting).
- When asked to create regions, do not create empty regions for groups that don't exist.
## Comments
- Add documentation /// comments to all Methods, Properties and Events.
- When adding /// comments, be sure to add them before any metadata annotations.
- When adding /// comments, if multiple lines are needed start with a summary line and include a blank line between the summary and remaining lines.
- When adding /// comments, explain parameters and surround parameter names with brackets. For example: "\[audio\]: The RealTime audio instance to use." and "\[name\]: The new name of the Widget."
- When adding /// comments to properties that are read / write, only add comments to the get method.
- When adding /// comments to something that explicitly throws an exception, document the exception at the bottom of the /// comment and surround it in brackets. For example: "Throws a \[StateError\] if the engine hasn't been started."
- When adding /// comments, use markdown syntax when it would be beneficial but do not use it excessively.
## Imports
- Always sort import statements alphabetically.
- There should not be any blank lines between import statements.
# Refactoring
- When asked to apply MyCodeStyle :
- Create code groups
- Create regions
- Sort regions
- Add documentation code comments