latest method Null safety

LicenseRecord? latest(
  1. String ptr,
  2. {String? origin}
)

Returns the latest LicenseRecord for a ptr or null if the title or license records are not found.

Optionally, an origin may be specified. If null origin defaults to the init origin.

The LicenseRecord returned may be expired or not applicable to a specific LicenseUse. To check license validity, use the guard method.

Implementation

LicenseRecord? latest(String ptr, {String? origin}) {
  ptr = _hashPtr(ptr);
  TitleModel? title = _titleService.getByPtr(ptr, origin: origin);
  if (title == null) return null;
  LicenseModel? license = _licenseService.getLatest(title.transactionId!);
  if (license == null) return null;
  return _toLicense(title, license);
}