如何,解决这个问题?错误:无法将参数类型“Duration?”分配给参数类型“Duration,”因为“Duration?”可为null,而“Duration”不可为null.
pw9qyyiw1#
如果您确定它不是这样,请将其转换为:
Duration? durationExample = Duration(seconds: 2); methodCallExample(durationExample as Duration);
或者在它为空时设置一个替代项:
Duration? durationExample = Duration(seconds: 10); methodCallExample(durationExample ?? Duration(seconds: 1));
1条答案
按热度按时间pw9qyyiw1#
如果您确定它不是这样,请将其转换为:
或者在它为空时设置一个替代项: