mediaRuleSetting function
The index of the last rule of rules holding on a screen width ×
height whose patch sets the field at path (["layout", "width"]),
or null when none does (the node's own value applies).
Implementation
int? mediaRuleSetting(List<MediaRule> rules, List<String> path, double width, double? height, Breakpoints breakpoints) {
int? out;
for (var i = 0; i < rules.length; i++) {
if (!rules[i].holds(width, height, breakpoints)) continue;
Object? v = rules[i].patch;
var found = true;
for (final k in path) {
if (v is Map && v.containsKey(k)) {
v = v[k];
} else {
found = false;
break;
}
}
if (found) out = i;
}
return out;
}