getInfo static method

Future<InfoBase?> getInfo(
  1. String url, {
  2. Duration? cache,
  3. bool multimedia = true,
  4. bool useMultithread = false,
})

Get web information return InfoBase

Implementation

static Future<InfoBase?> getInfo(String url,
    {Duration? cache,
    bool multimedia = true,
    bool useMultithread = false}) async {
  // final start = DateTime.now();

  InfoBase? info = getInfoFromCache(url);
  if (info != null) return info;

  try {
    if (useMultithread) {
      info = await _getInfoByIsolate(url, multimedia);
    } else {
      info = await _getInfo(url, multimedia);
    }

    if (cache != null && info != null) {
      info._timeout = DateTime.now().add(cache);
      _map[url] = info;
    }
  } catch (e) {
    print("Get web error: $url, Error: $e");
  }

  // print("$url cost ${DateTime.now().difference(start).inMilliseconds}");

  return info;
}