getAllMediaCssRule function

List<CssMediaRule> getAllMediaCssRule(
  1. String mediaCondition
)

Returns a list of @media CssRule with mediaCondition.

Implementation

List<CssMediaRule> getAllMediaCssRule(String mediaCondition) {
  mediaCondition = mediaCondition.trim();

  RegExp regExp;

  if (mediaCondition.isNotEmpty) {
    regExp = RegExp(r'^@media.*?\(\s*' + mediaCondition + r'\s*\)$',
        multiLine: false, caseSensitive: false);
  } else {
    regExp =
        RegExp(r'^@media.*?\(.*?\)', multiLine: false, caseSensitive: false);
  }

  var rules =
      selectCssRuleWithSelector(regExp).whereType<CssMediaRule>().toList();

  return rules;
}