PubCache class
Used to locate and manipulate the dart pub cache
Constructors
- PubCache()
-
factory
- PubCache.forScope()
-
Use this ctor to alter the location of .pub-cache
during testing.
factory
Properties
- cacheDir → String
-
Returns the directory name of the pub cache.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- pathTo ↔ String
-
The fully qualified path to the pub cache.
getter/setter pair
- pathToBin → String
-
The fully qualified path to the pub cache's bin directory
where executables from installed packages are stored.
no setter
- pathToDartLang → String
-
Path to the PubCache's hosted/pub.dartlang.org directory
where all of the downloaded packages from pub.dev live.
no setter
- pathToHosted → String
-
Path to the pub cache hosted directory
Prior to Dart 2.19: hosted/pub.dartlang.org
From Dart 2.19: this changed to hosted/pub.dev
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
findPrimaryVersion(
String packageName) → Version? - Finds and returns the latest (non-pre-release) version installed into pub cache for the given package.
-
findVersion(
String packageName, String requestedVersion) → String? -
Searches for
requestedVersion
ofpackageName
in pub-cache and returns the fully qualified path to that version. If the version is not found then null is returned; -
globalActivate(
String packageName, {String? version, bool verbose = false}) → void -
Run dart pub global activate on the given
packageName
. Ifversion
is passed then we activate the specific version otherwise we activate the latest version from the packages stable channel. Theverbose
option is for debugging activation problems and does a full dump to console of the dart pub log. -
globalActivateFromSource(
String path) → void -
Run dart pub global activate for a package located in
path
relative to the current directory. -
globalDeactivate(
String packageName) → void -
Run dart pub global deactivate on the given
packageName
. -
isGloballyActivated(
String packageName) → bool - returns true if the given package has been globally activated
-
isGloballyActivatedFromSource(
String packageName) → bool -
Returns true if the the dart project
packageName
is running from local source. This means that the package has been activated via -
isInstalled(
String packageName) → bool - Returns true if the package is installed in pub-cache
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pathToGlobalPackage(
String packageName) → String -
pathToPackage(
String packageName, String version) → String -
Returns the path to the package in .pub-cache for the dart
project named
packageName
for the versionversion
. e.g. ~/.pub-cache/hosted/pub.dartlang.org/dswitch-4.0.1 -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- envVarPubCache → const String
- The name of the environment variable that can be set to change the location of the .pub-cache directory. You should change this path by calling pathTo.