of static method
ComparedItem
of({
- required String id,
- String? label,
- PixelDiff? pixels,
- TreeDiff? tree,
- bool treeSkewed = false,
- List<
String> baseTexts = const [], - List<
String> headTexts = const [], - List<
Map< baseEvents = const [],String, Object?> > - List<
Map< headEvents = const [],String, Object?> > - bool baseRendered = true,
- bool headRendered = true,
- String? note,
- ({String base, String head})? shots,
Assembles the verdict from the channels.
The ladder is severity rather than arithmetic. A head that fails to render outranks everything: it is the result the tool exists to catch, and a percentage next to it would answer a smaller question. A base that fails is the opposite — it means the entry was already broken before this branch, which is worth stating once and quietly.
Implementation
static ComparedItem of({
required String id,
String? label,
PixelDiff? pixels,
TreeDiff? tree,
bool treeSkewed = false,
List<String> baseTexts = const [],
List<String> headTexts = const [],
List<Map<String, Object?>> baseEvents = const [],
List<Map<String, Object?>> headEvents = const [],
bool baseRendered = true,
bool headRendered = true,
String? note,
({String base, String head})? shots,
}) {
if (!headRendered) {
return ComparedItem(
id: id,
label: label,
state: baseRendered ? ComparedState.broke : ComparedState.failed,
note: note ?? (baseRendered ? 'renders on base, throws here' : null),
shots: shots,
);
}
if (!baseRendered) {
return ComparedItem(
id: id,
label: label,
state: ComparedState.wasBroken,
note: note ?? 'was already broken on base',
shots: shots,
);
}
var textChannel = TextChannel.of(base: baseTexts, head: headTexts);
var eventChannel = EventChannel.of(base: baseEvents, head: headEvents);
var treeChannel = tree == null
? null
: TreeChannel(tree, skewed: treeSkewed);
var pixelChannel = pixels == null ? null : PixelChannel(pixels);
// Events weigh in through [EventChannel.significant]: `system` chatter is
// compared and carried, but a step it is the whole of stays `same`. The
// channel is still stored below whenever it holds anything, which is what
// keeps the door open — the deltas ride `index.json`, they just do not
// decide the state.
var changed =
(pixelChannel?.changed ?? false) ||
(treeChannel?.significant ?? false) ||
textChannel.changed ||
eventChannel.significant;
return ComparedItem(
id: id,
label: label,
state: changed ? ComparedState.changed : ComparedState.same,
pixels: pixelChannel,
tree: treeChannel,
texts: textChannel.changed ? textChannel : null,
events: eventChannel.changed ? eventChannel : null,
note: note,
shots: shots,
);
}