diff --git a/packages/flutter/lib/src/gestures/hit_test.dart b/packages/flutter/lib/src/gestures/hit_test.dart index ba5150ad30..efa83d5b3f 100644 --- a/packages/flutter/lib/src/gestures/hit_test.dart +++ b/packages/flutter/lib/src/gestures/hit_test.dart @@ -47,14 +47,15 @@ class HitTestResult { /// If the [path] argument is null, the [path] field will be initialized with /// and empty list. HitTestResult({ List path }) - : path = path ?? []; + : _path = path ?? []; - /// The list of [HitTestEntry] objects recorded during the hit test. + /// An unmodifiable list of [HitTestEntry] objects recorded during the hit test. /// /// The first entry in the path is the most specific, typically the one at /// the leaf of tree being hit tested. Event propagation starts with the most /// specific (i.e., first) entry and proceeds in order through the path. - final List path; + List get path => new List.unmodifiable(_path); + final List _path; /// Add a [HitTestEntry] to the path. /// @@ -62,9 +63,9 @@ class HitTestResult { /// be added in order from most specific to least specific, typically during an /// upward walk of the tree being hit tested. void add(HitTestEntry entry) { - path.add(entry); + _path.add(entry); } @override - String toString() => 'HitTestResult(${path.isEmpty ? "" : path.join(", ")})'; + String toString() => 'HitTestResult(${_path.isEmpty ? "" : _path.join(", ")})'; }