What should be the output of the code below? Is this correct?


If I’m not wrong, this code should print:


but following is printed:


My code:

    import 'dart:mirrors';

    main() {
      var mirror = reflectType(dynamic);
      var symbol = mirror.qualifiedName;
      print(symbol); // -> "dynamic"


I think “dynamic” is a perfectly good result.

The usual qualified name prefixes the type name with the declaring library’s name.
You are expecting it to prefix “dart.core”, which is the name of the “dart:core” library, but “dynamic” is not declared in that library (https://api.dartlang.org/docs/channels/stable/latest/dart_core.html), so that would be the wrong prefix to use.

The “dynamic” type is a synthetic type that is not declared in any library – there is no “class” or “typedef” declaration that could declare a type behaving as “dynamic” does. It’s only specified by the specification and implemented internally in the compilers and runtime systems.

Having a qualified name with no prefix makes perfect sense in this case. It’s the same you get for “void”.

Answered By – lrn

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *