Skip to content

Inconsistent spacing when an initializer list is used with required arguments #1010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jamesderlin opened this issue Mar 29, 2021 · 0 comments · Fixed by #1015
Closed

Inconsistent spacing when an initializer list is used with required arguments #1010

jamesderlin opened this issue Mar 29, 2021 · 0 comments · Fixed by #1015

Comments

@jamesderlin
Copy link
Contributor

jamesderlin commented Mar 29, 2021

To reproduce, run dart format on:

class Foo {
  Foo({
    required int x,
  })  : assert(x != 0),
        assert(x != -1);
}

The result is:

class Foo {
  Foo({
    required int x,
  })   : assert(x != 0),
        assert(x != -1);
}

There are now three spaces instead of the usual two in front of the :, disrupting the alignment of the rest of the initializer list. This only seems to happen if:

  • There are multiple elements to the initializer list. If there's only one, there will be only a single space before the :.
  • The last construction parameter is required.
  • The construction parameters have a trailing comma.

What the initializer list members are doesn't seem to matter; they can be asserts, actual initializers, or calls to super().

I can reproduce this with DartPad (which as of writing, is based on Flutter 2.0.3 Dart SDK 2.12.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant