首页 > 解决方案 > For 循环神秘地没有运行,而其他循环却在运行

问题描述

我正在尝试运行隔离来运行我的离线散列身份验证功能。我将所有数据压缩到一个列表中,然后在函数中分配它。

出于某种奇怪的原因,第二个循环运行,而其他 2 个不运行。前两个是为了解决第三个不运行而创建的,现在第一个也不运行。我在这里想念什么?我从未见过没有抛出错误的循环不运行。

Future<bool> offlineAuthenticationThread(List<Tuple2<String, String>> storedCredentials) async {
  print('Isolate running');
  final DBCrypt hashing = DBCrypt();
  bool authorized = false;
  String userName = storedCredentials[0].item1;
  String password = storedCredentials[0].item2;
  List<String> usernameHashes = [];
  List<String> passwordHashes = [];
  storedCredentials.removeAt(0);

  for (var index = 0; index >= storedCredentials.length; index++) {
    print('1');
    usernameHashes.add(storedCredentials[index].item1);
    passwordHashes.add(storedCredentials[index].item2);
  }

  for (var index = 0; index >= usernameHashes.length; index++) {
    print('2');
    (hashing.checkpw(userName, usernameHashes[index]) && hashing.checkpw(password, passwordHashes[index]))
        ? authorized = true
        : authorized = false;
  }

  for (var index = 1; index >= storedCredentials.length; index++) {
    print('3');
    (hashing.checkpw(userName, storedCredentials[index].item1) &&
            hashing.checkpw(password, storedCredentials[index].item2))
        ? authorized = true
        : authorized = false;
  }
  return authorized;
}

标签: flutterloopsdart-isolates

解决方案


推荐阅读