insertRule method
Implementation
int insertRule(
String text,
int index, {
required double windowWidth,
required double windowHeight,
required bool isDarkMode,
}) {
// Parse with this stylesheet's href so relative URLs in inserted rules
// resolve against the stylesheet URL, not the document URL.
List<CSSRule> rules = CSSParser(text, href: href)
.parseRules(windowWidth: windowWidth, windowHeight: windowHeight, isDarkMode: isDarkMode);
if (index < 0 || index > cssRules.length) {
throw RangeError.index(index, cssRules, 'index');
}
cssRules.insertAll(index, rules);
for (final rule in rules) {
_assignParentStyleSheetRecursive(rule, this);
}
return index;
}