scan method
Scans view output for zone markers and returns the output with markers removed.
This should only be called at the root model level, not inside child components.
The scan:
- Parses all zone markers from the output
- Calculates screen positions for each zone
- Strips all markers from the output
- Stores zone info for later retrieval via get
Example
@override
String view() {
final content = renderChildren();
return zone.scan(content);
}
Note: An immediate call to get after scan should return the correct zone info, but for mouse events (which don't occur immediately after a render), the zone info will be available.
Implementation
String scan(String view) {
if (_closed) return view;
_iteration = DateTime.now().microsecondsSinceEpoch;
final zonesInThisScan = <String>{};
final scanner = ZoneScanner(
input: view,
iteration: _iteration,
enabled: _enabled,
onZone: (zoneInfo) {
_zones[zoneInfo.id] = zoneInfo;
zonesInThisScan.add(zoneInfo.id);
},
resolveId: _resolveId,
);
final result = scanner.run();
// Clean up zones from previous iterations that weren't in this scan
_zones.removeWhere((id, info) => !zonesInThisScan.contains(id));
return result;
}