hide combinator is a namespace modifier used within import and export directives to explicitly exclude specific identifiers from the current scope. It acts as a subtractive filter, allowing all members of a library to be visible except those listed after the keyword.
Syntax
Thehide combinator follows the URI string in a directive. Multiple identifiers are separated by commas.
Mechanics and Resolution
- Namespace Filtering: When the Dart compiler processes a directive containing
hide, it imports the entire public API of the referenced library but omits the specified symbols from the local namespace. - Compile-Time Enforcement: Attempting to reference a hidden identifier results in a compile-time error, stating that the name is not defined.
- Inverse Relationship:
hideis the functional inverse of theshowcombinator. Whileshowis additive (allow-list),hideis subtractive (deny-list). - Chaining: Combinators can be chained, though it is syntactically uncommon. The operations are applied sequentially.
Implementation Example
Consider a library namedgraphics.dart containing three classes:
hide combinator:
Export Behavior
When used with theexport directive, hide prevents specific members of the re-exported library from becoming part of the current library’s public API.
Master Dart with Deep Grasping Methodology!Learn More





