shouldGenerateFor method

  1. @override
bool shouldGenerateFor(
  1. BuildCandidate candidate
)
override

Determines whether this builder should generate output for the given candidate.

This method combines the generateFor patterns with the builder's own shouldBuildFor logic to determine if the builder should process the file.

candidate The build candidate to check.

Returns true if this builder should process the candidate.

Implementation

@override
bool shouldGenerateFor(BuildCandidate candidate) {
  if (generateFor.isNotEmpty) {
    for (final String pattern in generateFor) {
      final Glob glob = Glob(pattern);
      if (glob.matches(candidate.asset.uri.path)) {
        return builder.shouldBuildFor(candidate);
      }
    }
    return false;
  }
  return builder.shouldBuildFor(candidate);
}