diff --git a/packages/flutter/lib/src/foundation/diagnostics.dart b/packages/flutter/lib/src/foundation/diagnostics.dart index 55ffc3f910..a43bb1790a 100644 --- a/packages/flutter/lib/src/foundation/diagnostics.dart +++ b/packages/flutter/lib/src/foundation/diagnostics.dart @@ -2217,20 +2217,28 @@ class IterableProperty extends DiagnosticsProperty> { ); @override - String valueToString({ TextTreeConfiguration parentConfiguration }) { + String valueToString({TextTreeConfiguration parentConfiguration}) { if (value == null) return value.toString(); if (value.isEmpty) return ifEmpty ?? '[]'; + final Iterable formattedValues = value.map((T v) { + if (T == double && v is double) { + return debugFormatDouble(v); + } else { + return v.toString(); + } + }); + if (parentConfiguration != null && !parentConfiguration.lineBreakProperties) { // Always display the value as a single line and enclose the iterable // 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 diff --git a/packages/flutter/test/foundation/diagnostics_test.dart b/packages/flutter/test/foundation/diagnostics_test.dart index cd321cbbbb..31d7607e38 100644 --- a/packages/flutter/test/foundation/diagnostics_test.dart +++ b/packages/flutter/test/foundation/diagnostics_test.dart @@ -1611,6 +1611,15 @@ void main() { expect(intsProperty.isFiltered(DiagnosticLevel.info), isFalse); expect(intsProperty.toString(), equals('ints: 1, 2, 3')); + final List doubles = [1,2,3]; + final IterableProperty doublesProperty = IterableProperty( + '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 emptyProperty = IterableProperty( 'name', [],