Pubspec constructor

Pubspec(
  1. String name, {
  2. Version? version,
  3. String? publishTo,
  4. @Deprecated('See https://dart.dev/tools/pub/pubspec#authorauthors') String? author,
  5. @Deprecated('See https://dart.dev/tools/pub/pubspec#authorauthors') List<String>? authors,
  6. Map<String, VersionConstraint?>? environment,
  7. String? homepage,
  8. Uri? repository,
  9. Uri? issueTracker,
  10. List<Uri>? funding,
  11. List<String>? topics,
  12. List<Screenshot>? screenshots,
  13. String? documentation,
  14. String? description,
  15. Map<String, Dependency>? dependencies,
  16. Map<String, Dependency>? devDependencies,
  17. Map<String, Dependency>? dependencyOverrides,
  18. 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);
    }
  }
}