always_put_required_named_parameters_first
Required named parameters should be before optional named parameters.
Description
#The analyzer produces this diagnostic when required named parameters occur after optional named parameters.
Example
#The following code produces this diagnostic because the required parameter x
is after the optional parameter y
:
dart
void f({int? y, required int x}) {}
Common fixes
#Reorder the parameters so that all required named parameters are before any optional named parameters:
dart
void f({required int x, int? y}) {}
Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.