licenseName property

Future<String> licenseName

The license name associated with the package

Implementation

Future<String> get licenseName async {
  String? overriddenLicense = config.packageLicenseOverride[name];
  if (overriddenLicense != null) {
    return overriddenLicense;
  }

  if (licenseFile == null) {
    return noFileLicense;
  }

  String content = await licenseFile!.readAsString();
  pana_license_detector.Result res =
      await pana_license_detector.detectLicense(content, 0.9);
  // Just the first match (highest probability) as the license.
  return res.matches.isNotEmpty
      ? res.matches.first.identifier
      : unknownLicense;
}