get static method

Implementation

static Future<List<DGDirectLinkModel>> get(String url) async {
  final List<DGDirectLinkModel> links = [];
  final Completer<List<DGDirectLinkModel>> c =
      Completer<List<DGDirectLinkModel>>();
  DGHubWebScrapper.getFromWebView(
    url,
    onLoaded: (controller, gurl) async {
      await controller.evaluateJavascript(source: '''
document.querySelector('#sf_url').value = '$url'
document.querySelector('#sf_submit').click()
''');
    },
  ).then((document) async {
    await Future.delayed(const Duration(seconds: 3), () async {
      if (document != null) {
        try {
          /*String? thumbnail = document
              .querySelector(".media-result .clip img")
              ?.attributes['src'];
              print(thumbnail);*/
          var info = document.getElementsByClassName("info-box")[0];
          var linkGroup = info.querySelectorAll(".link-group a");
          if (kDebugMode) {
            print(linkGroup.length);
          }
          linkGroup.map((element) {
            String? href = element.attributes['href'];
            String? text = element.text;
            if (kDebugMode) {
              print(href.toString());
            }

            links.add(DGDirectLinkModel(
                quality: text.toString(), link: href.toString()));
            c.complete(links);
          });
        } catch (e) {
          if (kDebugMode) {
            print('Error social:$e');
          }
        }
      } else {
        if (kDebugMode) {
          print('Error social: Doc null error');
        }
      }
    });
  }).onError((error, stackTrace) {
    // print(error.toString());
    //  print(stackTrace.toString());
  });

  return c.future;
}