Pubspec constructor
Pubspec(
- String name, {
- Version? version,
- String? publishTo,
- @Deprecated('See https://dart.dev/tools/pub/pubspec#authorauthors') String? author,
- @Deprecated('See https://dart.dev/tools/pub/pubspec#authorauthors') List<
String> ? authors, - Map<
String, VersionConstraint?> ? environment, - String? homepage,
- Uri? repository,
- Uri? issueTracker,
- List<
Uri> ? funding, - List<
String> ? topics, - List<
Screenshot> ? screenshots, - String? documentation,
- String? description,
- Map<
String, Dependency> ? dependencies, - Map<
String, Dependency> ? devDependencies, - Map<
String, Dependency> ? dependencyOverrides, - Map<
String, dynamic> ? flutter,
If author
and authors
are both provided, their values are combined
with duplicates eliminated.
Implementation
Pubspec(
this.name, {
this.version,
this.publishTo,
@Deprecated(
'See https://dart.dev/tools/pub/pubspec#authorauthors',
)
String? author,
@Deprecated(
'See https://dart.dev/tools/pub/pubspec#authorauthors',
)
List<String>? authors,
Map<String, VersionConstraint?>? environment,
this.homepage,
this.repository,
this.issueTracker,
this.funding,
this.topics,
this.screenshots,
this.documentation,
this.description,
Map<String, Dependency>? dependencies,
Map<String, Dependency>? devDependencies,
Map<String, Dependency>? dependencyOverrides,
this.flutter,
}) :
// ignore: deprecated_member_use_from_same_package
authors = _normalizeAuthors(author, authors),
environment = environment ?? const {},
dependencies = dependencies ?? const {},
devDependencies = devDependencies ?? const {},
dependencyOverrides = dependencyOverrides ?? const {} {
if (name.isEmpty) {
throw ArgumentError.value(name, 'name', '"name" cannot be empty.');
}
if (publishTo != null && publishTo != 'none') {
try {
final targetUri = Uri.parse(publishTo!);
if (!(targetUri.isScheme('http') || targetUri.isScheme('https'))) {
throw const FormatException('Must be an http or https URL.');
}
} on FormatException catch (e) {
throw ArgumentError.value(publishTo, 'publishTo', e.message);
}
}
}