getURLPreview static method

Future<List<LocalCustomDataModel>> getURLPreview(
  1. List<String> urlMatches
)

Get the URL preview information

Implementation

static Future<List<LocalCustomDataModel>> getURLPreview(
    List<String> urlMatches) async {
  // Request for preview information for all URL links synchronously
  final List<LocalCustomDataModel> urlPreview =
  await Future.wait(urlMatches.map((e) async {
    String url = e;
    if (!e.contains("http")) {
      url = 'http://$e';
    }
    final WebInfo info = await LinkPreviewForUs.scrapeFromURL(url);

    return LocalCustomDataModel(
        url: e,
        title: info.title,
        image: info.image,
        description: info.description);
  }));

  return urlPreview;
}