verifyUniqueDestinationPath method Null safety

void verifyUniqueDestinationPath(
  1. MarkdownTemplate newMarkdownPage
)

Implementation

void verifyUniqueDestinationPath(MarkdownTemplate newMarkdownPage) {
  try {
    MarkdownTemplate existingMarkDownPageWithSameDestination =
        markdownPages.firstWhere((existingMarkDownPage) =>
            newMarkdownPage.destinationFilePath ==
            existingMarkDownPage.destinationFilePath);
    throw Exception(
        '${newMarkdownPage.sourceFilePath} and ${existingMarkDownPageWithSameDestination.sourceFilePath} both have the same destination path: ${newMarkdownPage.destinationFilePath}');
  } on StateError {
    // No double destination paths found. Perfect!
  }
}