show combinator is a namespace modifier applied to import and export directives. It functions as an exclusive allowlist, permitting only the explicitly specified identifiers to be visible within the current library scope while suppressing all other top-level members of the referenced library.
Syntax
The combinator follows the URI in the directive, followed by a comma-separated list of identifiers.Operational Semantics
- Namespace Filtering: When the Dart compiler processes a directive containing
show, it iterates through the top-level symbols of the target library. Only symbols matching the provided identifiers are bound to the current namespace. - Symbol Resolution: Any attempt to reference a symbol from the target library that is not included in the
showlist results in a compile-timeUndefined nameerror. - Granularity: The combinator applies only to top-level definitions (classes, functions, variables, typedefs, extensions, and mixins). It cannot filter static members or instance members within those definitions.
Implementation Example
Consider a library namedmath_utils.dart containing three top-level functions:
show combinator:
Export Behavior
When applied to anexport directive, show restricts which symbols from the re-exported library are exposed to consumers of the current library.
Master Dart with Deep Grasping Methodology!Learn More





