| 40 columns | |
| >>> Single cascade on same line. |
| "foo"..toString(); |
| <<< |
| "foo"..toString(); |
| >>> Split multiple cascades even if they fit. |
| foo..fooBar()..toString(); |
| <<< |
| foo |
| ..fooBar() |
| ..toString(); |
| >>> Split long single cascade but not after target. |
| "foo"..toString(argument, argument, argument); |
| <<< |
| "foo"..toString( |
| argument, |
| argument, |
| argument, |
| ); |
| >>> Split at target if single cascade doesn't fit. |
| "some much longer string"..someLongMethod(argument, argument); |
| <<< |
| "some much longer string" |
| ..someLongMethod(argument, argument); |
| >>> Split at target if single cascade doesn't fit. |
| "some much longer string"..someLongMethod(argument, argument, argument); |
| <<< |
| "some much longer string" |
| ..someLongMethod( |
| argument, |
| argument, |
| argument, |
| ); |
| >>> Split multiple cascades even if the same name. |
| list |
| ..add("baz") |
| ..add("bar"); |
| <<< |
| list |
| ..add("baz") |
| ..add("bar"); |
| >>> Setters. |
| foo..baz = 3..baz=5; |
| <<< |
| foo |
| ..baz = 3 |
| ..baz = 5; |
| >>> Don't indent contained block arguments if cascade doesn't split. |
| "foo"..toString(() {body;}); |
| <<< |
| "foo"..toString(() { |
| body; |
| }); |
| >>> Indent contained block arguments if cascade splits. |
| "foo"..another()..toString(() {body;}); |
| <<< |
| "foo" |
| ..another() |
| ..toString(() { |
| body; |
| }); |
| >>> Split if receiver precedence isn't obvious. |
| main() async { |
| // These are OK. |
| a = b..c(); |
| a += b..c(); |
| a.b..c(); |
| |
| // These are unclear. |
| a ? b : c..d(); |
| a ?? b..c(); |
| a && b..c(); |
| a || b..c(); |
| a == b..c(); |
| a <= b..c(); |
| a + b..c(); |
| a / b..c(); |
| a ^ b..c(); |
| a << b..c(); |
| -a..b(); |
| !a..b(); |
| --a..b(); |
| await a..b(); |
| } |
| <<< |
| main() async { |
| // These are OK. |
| a = b..c(); |
| a += b..c(); |
| a.b..c(); |
| |
| // These are unclear. |
| a ? b : c |
| ..d(); |
| a ?? b |
| ..c(); |
| a && b |
| ..c(); |
| a || b |
| ..c(); |
| a == b |
| ..c(); |
| a <= b |
| ..c(); |
| a + b |
| ..c(); |
| a / b |
| ..c(); |
| a ^ b |
| ..c(); |
| a << b |
| ..c(); |
| -a |
| ..b(); |
| !a |
| ..b(); |
| --a |
| ..b(); |
| await a |
| ..b(); |
| } |
| >>> Omit split if single section on list literal. |
| [veryLongElement,veryLongElement,veryLongElement,]..addAll(more); |
| <<< |
| [ |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| ]..addAll(more); |
| >>> Omit split if single section on map literal. |
| var map = {1: veryLongElement,2: veryLongElement,3: veryLongElement,}..addAll(more); |
| <<< |
| var map = { |
| 1: veryLongElement, |
| 2: veryLongElement, |
| 3: veryLongElement, |
| }..addAll(more); |
| >>> Omit split if single section on record literal. |
| (veryLongElement,veryLongElement,veryLongElement,)..addAll(more); |
| <<< |
| ( |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| )..addAll(more); |
| >>> Omit split if single section on function call. |
| foo(veryLongElement,veryLongElement,veryLongElement)..addAll(more); |
| <<< |
| foo( |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| )..addAll(more); |
| >>> Omit split if single section on instance creation. |
| new Foo(veryLongElement,veryLongElement,veryLongElement,)..addAll(more); |
| <<< |
| new Foo( |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| )..addAll(more); |
| >>> Omit split if single section on expression call. |
| (foo)(veryLongElement,veryLongElement,veryLongElement,)..addAll(more); |
| <<< |
| (foo)( |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| )..addAll(more); |
| >>> Prefer splitting inside collection instead of at cascade. |
| [element1, element2, element3] |
| ..cascade(); |
| <<< |
| [ |
| element1, |
| element2, |
| element3, |
| ]..cascade(); |
| >>> Don't force cascade to split on collection target if arg splits. |
| [1, 2, 3, 4]..cascade(() {;}); |
| <<< |
| [1, 2, 3, 4]..cascade(() { |
| ; |
| }); |
| >>> Don't force cascade to split on collection target if target and arg split. |
| [veryLongElement,veryLongElement,veryLongElement,]..cascade(() {;}); |
| <<< |
| [ |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| ]..cascade(() { |
| ; |
| }); |
| >>> Null-aware getter. |
| foo?..baz..baz; |
| <<< |
| foo |
| ?..baz |
| ..baz; |
| >>> Null-aware setter. |
| foo?..baz = 3..baz=5; |
| <<< |
| foo |
| ?..baz = 3 |
| ..baz = 5; |
| >>> Mixed null aware and regular cascades. |
| foo?..a()..b()..c(); |
| <<< |
| foo |
| ?..a() |
| ..b() |
| ..c(); |
| >>> Cascade index. |
| object..[index]..method()..[index]=value; |
| <<< |
| object |
| ..[index] |
| ..method() |
| ..[index] = value; |
| >>> Null-aware cascade index. |
| object?..[index]..method()..[index]=value; |
| <<< |
| object |
| ?..[index] |
| ..method() |
| ..[index] = value; |
| >>> Property chain in cascade. |
| object..first.second.third |
| ..fourth.fifth.sixth; |
| <<< |
| object |
| ..first.second.third |
| ..fourth.fifth.sixth; |
| >>> Split property chain in cascade. |
| object..firstProperty.secondProperty.thirdProperty |
| ..fourthProperty.fifthProperty.sixthProperty; |
| <<< |
| object |
| ..firstProperty |
| .secondProperty |
| .thirdProperty |
| ..fourthProperty |
| .fifthProperty |
| .sixthProperty; |
| >>> Cascade chained property access setter. |
| object..a.b = value; |
| <<< |
| object..a.b = value; |