enable always_put_control_body_on_new_line lint (#9950)
This commit is contained in:
parent
e4546584d1
commit
9b56c1c58c
@ -66,7 +66,7 @@ linter:
|
|||||||
|
|
||||||
# === style rules ===
|
# === style rules ===
|
||||||
- always_declare_return_types
|
- always_declare_return_types
|
||||||
# - always_put_control_body_on_new_line # not yet tested
|
- always_put_control_body_on_new_line
|
||||||
- always_require_non_null_named_parameters
|
- always_require_non_null_named_parameters
|
||||||
- always_specify_types
|
- always_specify_types
|
||||||
- annotate_overrides
|
- annotate_overrides
|
||||||
|
@ -64,7 +64,7 @@ linter:
|
|||||||
|
|
||||||
# === style rules ===
|
# === style rules ===
|
||||||
- always_declare_return_types
|
- always_declare_return_types
|
||||||
# - always_put_control_body_on_new_line # not yet tested
|
- always_put_control_body_on_new_line
|
||||||
- always_require_non_null_named_parameters
|
- always_require_non_null_named_parameters
|
||||||
- always_specify_types
|
- always_specify_types
|
||||||
- annotate_overrides
|
- annotate_overrides
|
||||||
|
@ -102,7 +102,8 @@ Future<TestStepResult> resultOfHandshake(
|
|||||||
dynamic error,
|
dynamic error,
|
||||||
) async {
|
) async {
|
||||||
assert(message != nothing);
|
assert(message != nothing);
|
||||||
while (received.length < 2) received.add(nothing);
|
while (received.length < 2)
|
||||||
|
received.add(nothing);
|
||||||
TestStatus status;
|
TestStatus status;
|
||||||
if (!_deepEquals(messageEcho, message) ||
|
if (!_deepEquals(messageEcho, message) ||
|
||||||
received.length != 2 ||
|
received.length != 2 ||
|
||||||
@ -136,11 +137,16 @@ String _toString(dynamic message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _deepEquals(dynamic a, dynamic b) {
|
bool _deepEquals(dynamic a, dynamic b) {
|
||||||
if (a == b) return true;
|
if (a == b)
|
||||||
if (a is double && a.isNaN) return b is double && b.isNaN;
|
return true;
|
||||||
if (a is ByteData) return b is ByteData && _deepEqualsByteData(a, b);
|
if (a is double && a.isNaN)
|
||||||
if (a is List) return b is List && _deepEqualsList(a, b);
|
return b is double && b.isNaN;
|
||||||
if (a is Map) return b is Map && _deepEqualsMap(a, b);
|
if (a is ByteData)
|
||||||
|
return b is ByteData && _deepEqualsByteData(a, b);
|
||||||
|
if (a is List)
|
||||||
|
return b is List && _deepEqualsList(a, b);
|
||||||
|
if (a is Map)
|
||||||
|
return b is Map && _deepEqualsMap(a, b);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,17 +158,21 @@ bool _deepEqualsByteData(ByteData a, ByteData b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _deepEqualsList(List<dynamic> a, List<dynamic> b) {
|
bool _deepEqualsList(List<dynamic> a, List<dynamic> b) {
|
||||||
if (a.length != b.length) return false;
|
if (a.length != b.length)
|
||||||
|
return false;
|
||||||
for (int i = 0; i < a.length; i++) {
|
for (int i = 0; i < a.length; i++) {
|
||||||
if (!_deepEquals(a[i], b[i])) return false;
|
if (!_deepEquals(a[i], b[i]))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _deepEqualsMap(Map<dynamic, dynamic> a, Map<dynamic, dynamic> b) {
|
bool _deepEqualsMap(Map<dynamic, dynamic> a, Map<dynamic, dynamic> b) {
|
||||||
if (a.length != b.length) return false;
|
if (a.length != b.length)
|
||||||
|
return false;
|
||||||
for (dynamic key in a.keys) {
|
for (dynamic key in a.keys) {
|
||||||
if (!b.containsKey(key) || !_deepEquals(a[key], b[key])) return false;
|
if (!b.containsKey(key) || !_deepEquals(a[key], b[key]))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -206,19 +206,23 @@ class _UsNumberTextInputFormatter extends TextInputFormatter {
|
|||||||
final StringBuffer newText = new StringBuffer();
|
final StringBuffer newText = new StringBuffer();
|
||||||
if (newTextLength >= 1) {
|
if (newTextLength >= 1) {
|
||||||
newText.write('(');
|
newText.write('(');
|
||||||
if (newValue.selection.end >= 1) selectionIndex++;
|
if (newValue.selection.end >= 1)
|
||||||
|
selectionIndex++;
|
||||||
}
|
}
|
||||||
if (newTextLength >= 4) {
|
if (newTextLength >= 4) {
|
||||||
newText.write(newValue.text.substring(0, usedSubstringIndex = 3) + ') ');
|
newText.write(newValue.text.substring(0, usedSubstringIndex = 3) + ') ');
|
||||||
if (newValue.selection.end >= 3) selectionIndex += 2;
|
if (newValue.selection.end >= 3)
|
||||||
|
selectionIndex += 2;
|
||||||
}
|
}
|
||||||
if (newTextLength >= 7) {
|
if (newTextLength >= 7) {
|
||||||
newText.write(newValue.text.substring(3, usedSubstringIndex = 6) + '-');
|
newText.write(newValue.text.substring(3, usedSubstringIndex = 6) + '-');
|
||||||
if (newValue.selection.end >= 6) selectionIndex++;
|
if (newValue.selection.end >= 6)
|
||||||
|
selectionIndex++;
|
||||||
}
|
}
|
||||||
if (newTextLength >= 11) {
|
if (newTextLength >= 11) {
|
||||||
newText.write(newValue.text.substring(6, usedSubstringIndex = 10) + ' ');
|
newText.write(newValue.text.substring(6, usedSubstringIndex = 10) + ' ');
|
||||||
if (newValue.selection.end >= 10) selectionIndex++;
|
if (newValue.selection.end >= 10)
|
||||||
|
selectionIndex++;
|
||||||
}
|
}
|
||||||
// Dump the rest.
|
// Dump the rest.
|
||||||
if (newTextLength >= usedSubstringIndex)
|
if (newTextLength >= usedSubstringIndex)
|
||||||
|
@ -14,7 +14,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tearDownAll(() async {
|
tearDownAll(() async {
|
||||||
if (driver != null) driver.close();
|
if (driver != null)
|
||||||
|
driver.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('tap on the button, verify result', () async {
|
test('tap on the button, verify result', () async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user