@@ -606,8 +606,8 @@ bool convertToBool(arg) {
606
606
#### DO name types using ` UpperCamelCase ` .
607
607
{:.no_toc}
608
608
609
- Classes and typedefs should capitalize the first letter of each word (including
610
- the first word), and use no separators.
609
+ Classes, enums, and typedefs should capitalize the first letter of each word
610
+ (including the first word), and use no separators.
611
611
612
612
<div class =" good " markdown =" 1 " >
613
613
{% prettify dart %}
@@ -628,7 +628,8 @@ typedef num Adder(num x, num y);
628
628
{:.no_toc}
629
629
<!-- https://github.com/dart-lang/www.dartlang.org/issues/831 -->
630
630
631
- In new code, use ` lowerCamelCase ` for constant variables.
631
+ In new code, use ` lowerCamelCase ` for constant variables, including enum
632
+ values.
632
633
633
634
In existing code that uses ` ALL_CAPS_WITH_UNDERSCORES ` for constants, you
634
635
may continue to use all caps to stay consistent.
@@ -1009,7 +1010,7 @@ compact. Do you really need to call that class
1009
1010
` AbstractWidgetFactoryManagerBuilder ` ?
1010
1011
1011
1012
1012
- #### DO place the operator on the preceding line in a multi-line expression.
1013
+ #### DO place binary operators on the preceding line in a multi-line expression.
1013
1014
{:.no_toc}
1014
1015
1015
1016
There are valid arguments for both styles but most of our code seems to go this
@@ -1042,6 +1043,31 @@ bobLikes()
1042
1043
</div >
1043
1044
1044
1045
1046
+ #### DO place ternary operators on the next line in a multi-line expression.
1047
+ {:.no_toc}
1048
+
1049
+ Also, if you break the line before one of the operators, prefer breaking
1050
+ around both.
1051
+
1052
+ <div class =" good " >
1053
+ {% prettify dart %}
1054
+ return someCondition
1055
+ ? whenTrue
1056
+ : whenFalse;
1057
+ {% endprettify %}
1058
+ </div >
1059
+
1060
+ <div class =" bad " >
1061
+ {% prettify dart %}
1062
+ return someCondition ?
1063
+ whenTrue :
1064
+ whenFalse;
1065
+ return someCondition
1066
+ ? whenTrue : whenFalse;
1067
+ {% endprettify %}
1068
+ </div >
1069
+
1070
+
1045
1071
#### DO place the ` . ` on the next line in a multi-line expression.
1046
1072
{:.no_toc}
1047
1073
@@ -1527,3 +1553,65 @@ followed by more alphanumeric text, the `{}` can and should be omitted.
1527
1553
"Wear your wildest ${decade}'s outfit."
1528
1554
{% endprettify %}
1529
1555
</div >
1556
+
1557
+
1558
+ ## Ordering
1559
+
1560
+ #### DO specify dart: imports, then package: imports, and then relative imports
1561
+ {:.no_toc}
1562
+
1563
+ Separate import sections from each other with a single blank line.
1564
+
1565
+ Within each section, prefer sorting alphabetically. If you use a
1566
+ ` package: ` import to import from your own package, consider putting
1567
+ that import in the relative import section.
1568
+
1569
+ <div class =" good " >
1570
+ {% prettify dart %}
1571
+ import 'dart: async ';
1572
+ import 'dart: convert ' show JSON;
1573
+ import 'dart: html ';
1574
+
1575
+ import 'package: bar /bar.dart'
1576
+ import 'package: bar /foo.dart'
1577
+ import 'package: foo /bar.dart'
1578
+
1579
+ import 'a.dart';
1580
+ {% endprettify %}
1581
+ </div >
1582
+
1583
+ <div class =" bad " >
1584
+ {% prettify dart %}
1585
+ import 'dart: html ';
1586
+ import 'dart: async ';
1587
+ import 'dart: convert ' show JSON;
1588
+
1589
+ import 'a.dart';
1590
+ import 'package: bar /bar.dart'
1591
+ import 'package: foo /bar.dart'
1592
+ import 'package: bar /foo.dart'
1593
+ {% endprettify %}
1594
+ </div >
1595
+
1596
+ #### PREFER specifying exports in a separate section after all imports
1597
+ {:.no_toc}
1598
+
1599
+ Put a single blank line above the exports section.
1600
+
1601
+ <div class =" good " >
1602
+ {% prettify dart %}
1603
+ import 'src/error.dart';
1604
+ import 'src/string_source.dart';
1605
+
1606
+ export 'src/error.dart';
1607
+ {% endprettify %}
1608
+ </div >
1609
+
1610
+ <div class =" bad " >
1611
+ {% prettify dart %}
1612
+ import 'src/error.dart';
1613
+ export 'src/error.dart';
1614
+
1615
+ import 'src/string_source.dart';
1616
+ {% endprettify %}
1617
+ </div >
0 commit comments