isCacheExpired property

bool get isCacheExpired

Check if the ad cache has expired

Each type of ad cache has a time limit, and if it exceeds the expiration time, it needs to be reloaded Returns true if the cache has expired and needs to be reloaded Returns false if the cache is still valid and can be used directly

Note: Only checks expiration if the ad is already loaded. If the ad hasn't finished loading yet, it's not considered expired.

Implementation

bool get isCacheExpired {
  // 只有已加载的广告才检查是否过期
  // 如果广告还没加载完成,不算过期
  if (!isLoaded || _loadedTime == null) {
    return false;
  }
  return DateTime.now().difference(_loadedTime!) > expireDuration;
}