dss function
Inserts a CSS rule with the given declarations markup and
returns a generated unique name to use as className
.
The examples show how you would use this function.
querySelector('someSelector').className = dss(''
'color: red;'
'font-size: 12px;');
final forIpad = '@media (min-width: 768px) and (max-width: 1024px)';
final box = dss('''
color: red;
$forIpad {
color: blue;
}
''');
void main() {
querySelector('someSelector')
..className = box
..text = 'I\'m normally red, but turn blue on an iPad.';
}
Implementation
String dss(String markup) {
String name = generateUniqueName();
parseAndInsert('.$name', markup);
return name;
}