record_ type_ one_ positional_ no_ trailing_ comma
A record type with exactly one positional field requires a trailing comma.
Description
#The analyzer produces this diagnostic when a record type annotation with a single positional field doesn't have a trailing comma after the field.
In some locations a record type 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 type has one positional field, but doesn't have a trailing comma:
void f((int) r) {}
Common fixes
#Add a trailing comma:
void f((int,) r) {}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.