BundleTarget class

The platform a bundle is built for, as conditional imports see it.

A configuration import 'a.dart' if (dart.library.io) 'b.dart'; is decided by the environment declarations of the platform that loads the library. The bundler resolves configurations when it builds the bundle (SCF16, decided for bundle time), so a bundle is specific to its target: one built for vm carries the dart.library.io branch, one built for web carries the default.

dart.library.<name> holds (as 'true') when libraries contains <name>; any other name is looked up in declarations.

Constructors

BundleTarget(String name, {required Set<String> libraries, Map<String, String> declarations = const {}})
A target with the given libraries and declarations.
const

Properties

declarations → Map<String, String>
Further environment declarations a condition may test.
final
hashCode → int
The hash code for this object.
no setterinherited
libraries → Set<String>
The dart: libraries the platform provides, without the dart: prefix.
final
name → String
Label for diagnostics, e.g. vm.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

holds(String declaration, String? value) → bool
Whether if (<declaration> == '<value>') holds on this platform; a missing value is Dart's implicit == 'true'.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override
valueOf(String declaration) → String?
The value the platform declares for declaration, or null.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

vm → const BundleTarget
The Dart VM, including Flutter on mobile and desktop.
web → const BundleTarget
Web compilers (dart2js / dart2wasm), including Flutter web.