readFrom method
Reads the surface from a screenshot already taken at path.
Implementation
Future<Scene> readFrom(String path) async {
lastReadProblem = null;
final List<RecognisedLine> lines;
try {
lines = await recognize(path);
} on Object catch (e) {
lastReadProblem = 'text recognition failed: $e';
return _sentinel();
}
final dpr = devicePixelRatio();
final root = SceneNode(depth: 0, indexInParent: -1, description: '_NativeRoot', type: 'native', inspectorId: '')
..glintId = '_native_root';
final used = <String, int>{};
root.children = [
for (final l in lines)
if (l.text.trim().isNotEmpty && l.w > 0 && l.h > 0)
SceneNode(
depth: 1,
indexInParent: 0,
description: 'text',
type: 'native',
inspectorId: '',
widgetRuntimeType: 'text',
textPreview: l.text.trim(),
createdByLocalProject: true,
)
..glintId = _id(l.text, used)
..isNativeEnabled = true
..axFrame = (x: l.x / dpr, y: l.y / dpr, w: l.w / dpr, h: l.h / dpr),
];
return Scene.native(root: root);
}