flutter 列表sort排序前要判断是否为null

列表sort排序前要判断是否为null,如下

    wsImMessageList.sort((left, right) {
      if (right.sendTime != null && left.sendTime != null) {
        return right.sendTime!.compareTo(left.sendTime!);
      } else {
        return -1;
      }
    });

你可能感兴趣的:(flutter,flutter)