getFirstTextStyle method

TextStyle? getFirstTextStyle(
  1. bool addIfNotExists
)

Get the first available TextStyle.

If addIfNotExists is true, then a new style is added to the first rule.

Implementation

TextStyle? getFirstTextStyle(bool addIfNotExists) {
  var allRules = getAllRules();
  var firstRule;
  var hasOne = false;
  for (var rules in allRules) {
    for (var rule in rules) {
      firstRule ??= rule;
      hasOne = true;
      if (rule.textSymbolizers.isNotEmpty) {
        return rule.textSymbolizers[0].style;
      }
    }
  }
  if (addIfNotExists && hasOne) {
    var textStyle = TextStyle();
    firstRule.addTextStyle(textStyle);
    return textStyle;
  } else {
    return null;
  }
}