next method Null safety

Version next(
  1. NextVersion nextVersion
)

The next version from the given string.

Implementation

Version next(NextVersion nextVersion) {
  switch (nextVersion) {
    case NextVersion.major:
      return nextMajor;
    case NextVersion.minor:
      return nextMinor;
    case NextVersion.patch:
      return nextPatch;
    case NextVersion.build:
      final currentBuildNumber = int.tryParse(build.join()) ?? 0;
      return copy(
        build: (currentBuildNumber + 1).toString(),
      );
    case NextVersion.breaking:
      return nextBreaking;
  }
}