outMap function Null safety

void outMap(
  1. TagContext tc,
  2. Map<String, String> map
)

Output the given map to the generated Dart file. It will generate something like the following to the Dart file:

{"key1": "value1", "key2": value2_in_EL}

A value can contain EL expressions, such as [=foo_expression]. However, the keys are output directly, so make sure it does not contain invalid characters.

Implementation

void outMap(TagContext tc, Map<String, String> map) {
  tc.write("{");
  bool first = true;
  for (final key in map.keys) {
    if (first) first = false;
    else tc.write(", ");

    tc.write("'");
    tc.write(key);
    tc.write("': ");
    tc.write(toEL(map[key])); //Rsp.cat can handle non-string value
  }
  tc.write("}");
}