sort-child-properties-last

Same as sort_child_properties_last in Dart lints

Group
Style
Path
lint/style/sort-child-properties-last
Default
On (recommended)
Origin
Dart lints
Domain
flutter
Rule
436 of 512
recommendedflutter

Sort Widget-valued child properties last, except before closure arguments.

Invalid

example.dartdart
// Bad: the child/children argument is not last in a widget constructor call.
import 'package:flutter/material.dart';

Widget b0() => Center(child: Text('a'), key: Key('k'));

Widget b1() => Column(children: [Text('a'), Text('b')], key: Key('k'));

Widget b2() => Padding(child: Text('a'), padding: EdgeInsets.zero);

Widget b3() => Container(child: Text('a'), width: 10);

Widget b4() => SizedBox(child: Text('a'), width: 10, height: 10);
The child/children argument should be last in a widget constructor call.
3
4Widget b0() => Center(child: Text('a'), key: Key('k'));
The child/children argument should be last in a widget constructor call.
5
6Widget b1() => Column(children: [Text('a'), Text('b')], key: Key('k'));
The child/children argument should be last in a widget constructor call.
7
8Widget b2() => Padding(child: Text('a'), padding: EdgeInsets.zero);
The child/children argument should be last in a widget constructor call.
9
10Widget b3() => Container(child: Text('a'), width: 10);
The child/children argument should be last in a widget constructor call.
11
12Widget b4() => SizedBox(child: Text('a'), width: 10, height: 10);

Valid

example.dartdart
// Good: child/children is last, absent, or the call is not a widget constructor.
import 'package:flutter/material.dart';

Widget g0() => Center(key: Key('k'), child: Text('a'));

Widget g1() => Column(key: Key('k'), children: [Text('a'), Text('b')]);

Widget g2() => Padding(padding: EdgeInsets.zero, child: Text('a'));

Widget g3() => Text('no child');

Widget g4() => SizedBox(width: 10, height: 10, child: Text('a'));

Widget g5() => Center(child: Text('a'));

int g6() => doWork(child: 5, other: 6);

Configure sort-child-properties-last

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "sort-child-properties-last": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/style/sort-child-properties-last: <reason>
  • sort-constructors-firstsort_constructors_first

    Flags a constructor declared after a non-constructor member.

  • sort-unnamed-constructors-firstsort_unnamed_constructors_first

    Flags an unnamed constructor declared after a named constructor.

  • tighten-type-of-initializing-formalstighten_type_of_initializing_formals

    Flags a nullable this.x or super.x initializing formal whose constructor asserts x != null.

  • type-annotate-public-apistype_annotate_public_apisrecommended

    Requires type annotations on public declarations.

  • type-init-formalstype_init_formalsrecommended

    Flags a *redundant* type annotation on an initializing formal or super parameter (type-init-formals, adopted from package:lints).

  • unawaited-futuresunawaited_futuresrecommended

    Future results in async bodies must be awaited or marked unawaited.

  • unintended-html-in-doc-commentunintended_html_in_doc_commentrecommended

    Flags angle-bracket text in doc comments that Markdown would render as an HTML tag.

  • unnecessary-await-in-returnunnecessary_await_in_return

    Avoid await on a returned Future the function's own Future already covers.