record_literal_one_positional_no_trailing_comma
A record literal with exactly one positional field requires a trailing comma.
Description
#The analyzer produces this diagnostic when a record literal with a single positional field doesn't have a trailing comma after the field.
In some locations a record literal with a single positional field could also be a parenthesized expression. A trailing comma is required to disambiguate these two valid interpretations.
Example
#The following code produces this diagnostic because the record literal has one positional field but doesn't have a trailing comma:
dart
var r = const (1);
Common fixes
#Add a trailing comma:
dart
var r = const (1,);
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。