PubSpec class

Represents a pubspec.

Example Usage:

// load it
var pubSpec = await PubSpec.load(myDirectory);

// change the dependencies to a single path dependency on project 'foo'
var PubSpec = pubSpec.copy(dependencies: { 'foo': PathReference('../foo') });

// save it
await PubSpec.save(myDirectory);

Constructors

PubSpec({String? name, String? author, Version? version, String? homepage, String? documentation, String? description, Uri? publishTo, Environment? environment, Map<String, DependencyReference> dependencies = const {}, Map<String, DependencyReference> devDependencies = const {}, Map<String, DependencyReference> dependencyOverrides = const {}, Map<String, Executable> executables = const {}, Map? unParsedYaml = const {}})
PubSpec.fromJson(Map? json)
factory
PubSpec.fromYamlString(String yamlString)
factory

Properties

allDependencies Map<String, DependencyReference>
dependencies and devDependencies combined. Does not include dependencyOverrides
no setter
author String?
final
dependencies Map<String, DependencyReference>
final
dependencyOverrides Map<String, DependencyReference>
final
description String?
final
devDependencies Map<String, DependencyReference>
final
documentation String?
final
environment Environment?
final
executables Map<String, Executable>
final
hashCode int
The hash code for this object.
no setterinherited
homepage String?
final
name String?
final
publishTo Uri?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unParsedYaml Map?
final
version → Version?
final

Methods

copy({String? name, String? author, Version? version, String? homepage, String? documentation, String? description, Uri? publishTo, Environment? environment, Map<String, DependencyReference>? dependencies, Map<String, DependencyReference>? devDependencies, Map<String, DependencyReference>? dependencyOverrides, Map<String, Executable>? executables, Map? unParsedYaml}) PubSpec
creates a copy of the pubspec with the changes provided
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
save(Directory projectDirectory) Future
saves the pubspec to the projectDirectory
toJson() Map
Converts to a Map that can be serialised to Yaml or Json
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

load(Directory projectDirectory) Future<PubSpec>
loads the pubspec from the projectDirectory
loadFile(String file) Future<PubSpec>
loads the pubspec from the file