From eb44210a771070e7ce238958cc06facd77210e2b Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Wed, 19 Jul 2017 14:41:07 -0700 Subject: [PATCH] Cleaner RRect.toString (flutter/engine#3906) Will make debugging layer trees with PhysicalLayers easier. --- engine/src/flutter/lib/ui/geometry.dart | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/lib/ui/geometry.dart b/engine/src/flutter/lib/ui/geometry.dart index ec20fd5ae5f..b0b5efee2d5 100644 --- a/engine/src/flutter/lib/ui/geometry.dart +++ b/engine/src/flutter/lib/ui/geometry.dart @@ -1342,11 +1342,24 @@ class RRect { @override String toString() { - return 'RRect.fromLTRBAndCorners(${left.toStringAsFixed(1)}, ' - '${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ' - '${bottom.toStringAsFixed(1)}, ' - 'topLeft: $tlRadius, topRight: $trRadius, ' - 'bottomRight: $brRadius, bottomLeft: $blRadius)'; + final String rect = '${left.toStringAsFixed(1)}, ' + '${top.toStringAsFixed(1)}, ' + '${right.toStringAsFixed(1)}, ' + '${bottom.toStringAsFixed(1)}'; + if (tlRadius == trRadius && + trRadius == brRadius && + brRadius == blRadius) { + if (tlRadius.x == tlRadius.y) + return 'RRect.fromLTRBR($rect, ${tlRadius.x.toStringAsFixed(1)})'; + return 'RRect.fromLTRBXY($rect, ${tlRadius.x.toStringAsFixed(1)}, ${tlRadius.y.toStringAsFixed(1)})'; + } + return 'RRect.fromLTRBAndCorners(' + '$rect, ' + 'topLeft: $tlRadius, ' + 'topRight: $trRadius, ' + 'bottomRight: $brRadius, ' + 'bottomLeft: $blRadius' + ')'; } }