当我尝试使用在 dart 中工作的代码时出现 Flutter http 错误

Flutter http error when I try to use code that works in dart

我是 Flutter 的新手,我想创建一个应用程序来帮助我解决化学方程式,为此我创建了这个函数:

    void main() {
  String m = "H2O";
  String n = "H2O";
  parser(m, n);
}

parser(m, n) async {
  var client = Client();
  Response response = await client
      .get(Uri.parse('https://chemequations.com/ru/?s=$m+%2B+$n&ref=input'));
  var x = parse(response.body);
  print(x.getElementsByClassName("equation main-equation well")[0].text);
}

这种结构在 dart 中运行得非常好,并在控制台中打印正确的结果,但在 flutter 中我想将它与 SetState 方法一起使用,但我什至无法在控制台中打印结果。它抛出一个错误:

Error: XMLHttpRequest error.

请帮帮我。谢谢

发生错误是因为我在 web 中启动了应用程序。刚开始从移动模拟器调试,错误消失了