match method

int? match(
  1. int? sceneid,
  2. Map<String, dynamic> queryParameters
)

Implementation

int? match(int? sceneid, Map<String, dynamic> queryParameters) {
  if (sceneid == 0) {
    //自动模式: 通过参数匹配
    for (MockScene item in scenes ?? []) {
      if (item.params?.any((element) =>
              queryParameters[item.name.toLowerCase()] == element.value) ??
          false) {
        return item.id;
      }
    }
  }
  var scene =
      scenes?.firstWhere((element) => element.id == sceneid && sceneid != 0);
  scene ??= scenes?.firstWhere((element) => element.id > 0);
  return scene?.id;
}