Victor Savkin Victor Savkin - 3 years ago 289
Dart Question

Converting a Symbol into a String

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?

Answer Source

Use MirrorSystem.getName():

import 'dart:mirrors';

void main() {
  var sym = new Symbol('test');

This outputs:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download