sort_ child_ properties_ last
The '{0}' argument should be last in widget constructor invocations.
Description
#
The analyzer produces this diagnostic when the
child
or
children
argument isn't the last argument in an invocation of a widget class'
constructor. An exception is made if all of the arguments after the
child
or
children
argument are function expressions.
Example
#
The following code produces this diagnostic because the
child
argument
isn't the last argument in the invocation of the
Center
constructor:
import 'package:flutter/material.dart';
Widget createWidget() {
return Center(
child: Text('...'),
widthFactor: 0.5,
);
}
Common fixes
#Move the child
or children
argument to be last:
import 'package:flutter/material.dart';
Widget createWidget() {
return Center(
widthFactor: 0.5,
child: Text('...'),
);
}
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.