What is a Dart symbol?

In Dart, a symbol object represents an operator or identifier declared in a Dart program. Symbols cannot be changed as they are compile-time constants. This makes them invaluable for APIs that refer to identifiers by name because minification replaces identifier names, but not identifier symbols.

Symbols are rarely used these days and libraries, like the MirrorSystem that supports them, have been deprecated.

Minification reduces file size to send files over a network
Minification reduces file size to send files over a network

Usage

Prefixing any identifier with # makes it into a symbol literal:

#foo
#bar
// To get the symbol for an identifier, use a symbol literal, which is just # followed by the identifier

The syntax to declare a symbol is:

import 'dart:convert';
void main() {
Symbol object = new Symbol('name');
// name must be a valid public Dart member name, public constructor name, or library name.
print(object);
}

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved