From 324a2168cd77266d9abd5a2c1a53460c9d01b71f Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Fri, 7 Feb 2020 13:08:02 -0800 Subject: [PATCH] Change definition of offset to object (#50157) --- packages/flutter/lib/src/rendering/layer.dart | 13 ++++++------- .../test/rendering/layer_annotations_test.dart | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/flutter/lib/src/rendering/layer.dart b/packages/flutter/lib/src/rendering/layer.dart index 67c6445965..9ef5a244f9 100644 --- a/packages/flutter/lib/src/rendering/layer.dart +++ b/packages/flutter/lib/src/rendering/layer.dart @@ -30,8 +30,8 @@ class AnnotationEntry { /// The annotation object that is found. final T annotation; - /// The target location described by the local coordinate space of the layer - /// that contains the annotation. + /// The target location described by the local coordinate space of the + /// annotation object. final Offset localPosition; @override @@ -2470,16 +2470,15 @@ class AnnotatedRegionLayer extends ContainerLayer { /// met. final T value; - /// The size of an optional clipping rectangle, used to control whether a - /// position is contained by the annotation. + /// The size of the annotated object. /// - /// If [size] is provided, then the annotation is only added if the target + /// If [size] is provided, then the annotation is found only if the target /// position is contained by the rectangle formed by [size] and [offset]. /// Otherwise no such restriction is applied, and clipping can only be done by /// the ancestor layers. final Size size; - /// The offset of the optional clipping rectangle that is indicated by [size]. + /// The position of the annotated object. /// /// The [offset] defaults to [Offset.zero] if not provided, and is ignored if /// [size] is not set. @@ -2549,7 +2548,7 @@ class AnnotatedRegionLayer extends ContainerLayer { final S typedValue = untypedValue as S; result.add(AnnotationEntry( annotation: typedValue, - localPosition: localPosition, + localPosition: localPosition - offset, )); } return isAbsorbed; diff --git a/packages/flutter/test/rendering/layer_annotations_test.dart b/packages/flutter/test/rendering/layer_annotations_test.dart index dbb8c78f98..f0420cc58b 100644 --- a/packages/flutter/test/rendering/layer_annotations_test.dart +++ b/packages/flutter/test/rendering/layer_annotations_test.dart @@ -690,7 +690,7 @@ void main() { root.findAllAnnotations(position).entries.toList(), _equalToAnnotationResult(>[ const AnnotationEntry(annotation: 2, localPosition: position), - const AnnotationEntry(annotation: 1, localPosition: position), + const AnnotationEntry(annotation: 1, localPosition: Offset(10, 10)), const AnnotationEntry(annotation: 1000, localPosition: position), ]), );