如何检查 onWillPop 值是否为空?

How to check for null on onWillPop values?

我需要做一个空检查:

onWillPop: () async {
        return !await listOfKeys[tabController!.index].currentState!.maybePop();
      },
代替 ”!”我应该使用“??”。但我不能把它写下来。我该怎么做?

当您使用空安全运算符“??”时,您应该提供一个回退值:

    onWillPop: () async {
      return tabController != null
      ? !(await listOfKeys[tabController?.index].currentState?.maybePop() ?? false)
      : false;
    },