parseSample function

Map<String, Object?>? parseSample(
  1. String line
)

Parses line into a (metric, value) sample, or null.

The envelope is searched anywhere in the line, not only at its start: under flutter drive the app's stdout is prefixed by the tool (I/flutter ( <pid>): ...), while plain flutter test prints raw.

Implementation

Map<String, Object?>? parseSample(String line) {
  final start = line.indexOf(envelope);
  if (start < 0) return null;
  final payload = line.substring(start + envelope.length).trim();
  final decoded = jsonDecode(payload) as Map<String, dynamic>;
  return decoded.cast<String, Object?>();
}