Converting a Symbol into a String

dart

Solution

Use MirrorSystem.getName():

import 'dart:mirrors';

void main() {
  var sym = new Symbol('test');
  print(MirrorSystem.getName(sym));
}

This outputs:

test

Problem

Is there a way to covert a Symbol into a String? For instance, a VariableMirror returns Symbols instead of Strings. Is there a way to convert a Symbol into a String, so I can print all the variable names of a class?

Original source