Dart对您的程序进行了分析,发现您尚未处理如何退出该方法的所有情况。这是一个潜在的问题,因为您的方法签名指定您的方法正在返回Future<User>
对象。
In your case you have not handled the case where an exception are throw from the createUserWithEmailAndPassword
method. If an exception are catch, you ends up with a execution path without any return
statement.
In this case, Dart will at runtime just return null
so it is not an error. But it is a potential sign of a code error since it it not unlikely that you have forgotten the handling of the exception by not have any return
statement.
If it is your intention to just return null
in case of an exception, you should therefore have insert return null;
in both of your catch
blocks (or just at the bottom of your method outside the catch-blocks).
另外,rethrow
如果您只想添加一些日志记录,但仍然让调用者也可以处理异常,则可以设置异常。您可以在语言导览中阅读有关此内容的更多信息:https : //dart.dev/guides/language/language-tour#catch
在这两种情况下,都应在方法文档中描述其行为。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句