Commit e190327f authored by Adam Barth's avatar Adam Barth

HitTestResult.path should be unmodifiable (#4482)

Fixes #4428
parent f75fd5c3
...@@ -47,14 +47,15 @@ class HitTestResult { ...@@ -47,14 +47,15 @@ class HitTestResult {
/// If the [path] argument is null, the [path] field will be initialized with /// If the [path] argument is null, the [path] field will be initialized with
/// and empty list. /// and empty list.
HitTestResult({ List<HitTestEntry> path }) HitTestResult({ List<HitTestEntry> path })
: path = path ?? <HitTestEntry>[]; : _path = path ?? <HitTestEntry>[];
/// 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 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 /// 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. /// specific (i.e., first) entry and proceeds in order through the path.
final List<HitTestEntry> path; List<HitTestEntry> get path => new List<HitTestEntry>.unmodifiable(_path);
final List<HitTestEntry> _path;
/// Add a [HitTestEntry] to the path. /// Add a [HitTestEntry] to the path.
/// ///
...@@ -62,9 +63,9 @@ class HitTestResult { ...@@ -62,9 +63,9 @@ class HitTestResult {
/// be added in order from most specific to least specific, typically during an /// be added in order from most specific to least specific, typically during an
/// upward walk of the tree being hit tested. /// upward walk of the tree being hit tested.
void add(HitTestEntry entry) { void add(HitTestEntry entry) {
path.add(entry); _path.add(entry);
} }
@override @override
String toString() => 'HitTestResult(${path.isEmpty ? "<empty path>" : path.join(", ")})'; String toString() => 'HitTestResult(${_path.isEmpty ? "<empty path>" : _path.join(", ")})';
} }
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