parseMetaContent function

Map<String, String?> parseMetaContent(
  1. String content
)

Parses a meta content to Map<String,String>.

Implementation

Map<String, String?> parseMetaContent(String content) {
  var parts = content.split(RegExp(r'\s*,\s*'));

  // ignore: omit_local_variable_types
  Map<String, String?> map = {};

  for (var p in parts) {
    var pair = split(p, '=', 2);

    if (pair.length == 1) {
      map[p] = null;
    } else {
      var key = pair[0].trim();
      var val = pair[1].trim();
      map[key] = val;
    }
  }

  return map;
}