create static method

Pubspec create({
  1. bool schemeUtilsIsSetDefaultData = false,
  2. String special_type = "pubspec",
  3. String? name,
  4. String? description,
  5. String? version,
  6. String? homepage,
  7. String? repository,
  8. String? issue_tracker,
  9. String? documentation,
  10. List<String>? funding,
  11. List<String>? topics,
  12. Environment? environment,
  13. Dependencies? dependencies,
  14. DevDependencies? dev_dependencies,
  15. DependencyOverrides? dependency_overrides,
  16. Platforms? platforms,
})
override

return original data json

Implementation

static Pubspec create({
  bool schemeUtilsIsSetDefaultData = false,
  String special_type = "pubspec",
  String? name,
  String? description,
  String? version,
  String? homepage,
  String? repository,
  String? issue_tracker,
  String? documentation,
  List<String>? funding,
  List<String>? topics,
  Environment? environment,
  Dependencies? dependencies,
  DevDependencies? dev_dependencies,
  DependencyOverrides? dependency_overrides,
  Platforms? platforms,
}) {
  // Pubspec pubspec = Pubspec({
  final Map pubspec_data_create_json = {
    "@type": special_type,
    "name": name,
    "description": description,
    "version": version,
    "homepage": homepage,
    "repository": repository,
    "issue_tracker": issue_tracker,
    "documentation": documentation,
    "funding": funding,
    "topics": topics,
    "environment": (environment != null) ? environment.toJson() : null,
    "dependencies": (dependencies != null) ? dependencies.toJson() : null,
    "dev_dependencies":
        (dev_dependencies != null) ? dev_dependencies.toJson() : null,
    "dependency_overrides":
        (dependency_overrides != null) ? dependency_overrides.toJson() : null,
    "platforms": (platforms != null) ? platforms.toJson() : null,
  };

  pubspec_data_create_json.removeWhere((key, value) => value == null);

  if (schemeUtilsIsSetDefaultData) {
    defaultData.forEach((key, value) {
      if (pubspec_data_create_json.containsKey(key) == false) {
        pubspec_data_create_json[key] = value;
      }
    });
  }
  return Pubspec(pubspec_data_create_json);
}