Unverified Commit 7c27142e authored by Ferhat's avatar Ferhat Committed by GitHub

Upstream web support for IterableProperty<double> (#37515)

* Upstream web support for IterableProperty<double>
parent 35b6d668
...@@ -2217,20 +2217,28 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> { ...@@ -2217,20 +2217,28 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> {
); );
@override @override
String valueToString({ TextTreeConfiguration parentConfiguration }) { String valueToString({TextTreeConfiguration parentConfiguration}) {
if (value == null) if (value == null)
return value.toString(); return value.toString();
if (value.isEmpty) if (value.isEmpty)
return ifEmpty ?? '[]'; return ifEmpty ?? '[]';
final Iterable<String> formattedValues = value.map((T v) {
if (T == double && v is double) {
return debugFormatDouble(v);
} else {
return v.toString();
}
});
if (parentConfiguration != null && !parentConfiguration.lineBreakProperties) { if (parentConfiguration != null && !parentConfiguration.lineBreakProperties) {
// Always display the value as a single line and enclose the iterable // Always display the value as a single line and enclose the iterable
// value in brackets to avoid ambiguity. // value in brackets to avoid ambiguity.
return '[${value.join(', ')}]'; return '[${formattedValues.join(', ')}]';
} }
return value.join(_isSingleLine(style) ? ', ' : '\n'); return formattedValues.join(_isSingleLine(style) ? ', ' : '\n');
} }
/// Priority level of the diagnostic used to control which diagnostics should /// Priority level of the diagnostic used to control which diagnostics should
......
...@@ -1611,6 +1611,15 @@ void main() { ...@@ -1611,6 +1611,15 @@ void main() {
expect(intsProperty.isFiltered(DiagnosticLevel.info), isFalse); expect(intsProperty.isFiltered(DiagnosticLevel.info), isFalse);
expect(intsProperty.toString(), equals('ints: 1, 2, 3')); expect(intsProperty.toString(), equals('ints: 1, 2, 3'));
final List<double> doubles = <double>[1,2,3];
final IterableProperty<double> doublesProperty = IterableProperty<double>(
'doubles',
doubles,
);
expect(doublesProperty.value, equals(doubles));
expect(doublesProperty.isFiltered(DiagnosticLevel.info), isFalse);
expect(doublesProperty.toString(), equals('doubles: 1.0, 2.0, 3.0'));
final IterableProperty<Object> emptyProperty = IterableProperty<Object>( final IterableProperty<Object> emptyProperty = IterableProperty<Object>(
'name', 'name',
<Object>[], <Object>[],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment