isPartFile function

bool isPartFile(
  1. String path
)

Implementation

bool isPartFile(String path) {
  try {
    final result = parseFile(
      path: File(path).absolute.path,
      featureSet: FeatureSet.latestLanguageVersion(),
      throwIfDiagnostics: false,
    );

    return result.unit.directives.whereType<PartOfDirective>().isNotEmpty;
  } catch (e) {
    return false;
  }
}