Skip to content

Inconsistent formatting of shorthand lambda expressions when passed as a named argument #1679

@jellynoone

Description

@jellynoone

Consider

void something() => functionCall(
  'Hello world!',
  'Good night city!',
  'Goodbye, world!',
  'Afterwards',
);

class Something {
  void something() => functionCall(
    'Hello world!',
    'Good night city!',
    'Goodbye, world!',
    'Afterwards',
  );
}
void main() {
  final result = switch (value) {
    Something() => functionCall(
      'Hello world!',
      'Good night city!',
      'Goodbye, world!',
    ),
  };

  calling(
    () => functionCall(
      'Hello world!',
      'Good night city!',
      'Goodbye, world!',
      'Afterwards',
    ),
  );

  calling(
    function:
        () => functionCall(
          'Hello world!',
          'Good night city!',
          'Goodbye, world!',
          'Afterwards',
        ),
  );
}

The last call to: calling(function:)) feels inconsistent with the other formatting.

Expected:

  calling(
    function: () => functionCall(
        'Hello world!',
        'Good night city!',
        'Goodbye, world!',
        'Afterwards',
      ),
  );

Rational:

  • function: () =>
  • something() =>
  • Something() =>
  • Something.something() =>
    All feel similar as in it's a label that points to an expression to be executed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions