prefer_asserts_with_message
Details about the 'prefer_asserts_with_message' diagnostic produced by the Dart analyzer.
Missing a message in an assert.
Description
#The analyzer produces this diagnostic when an assert statement doesn't have a message.
Example
#The following code produces this diagnostic because there's no message in the assert statement:
dart
void f(String s) {
assert(s.isNotEmpty);
}
Common fixes
#Add a message to the assert statement:
dart
void f(String s) {
assert(s.isNotEmpty, 'The argument must not be empty.');
}
Was this page's content helpful?
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.