Skip to content

[Formatting issue] Weird linebreaks in loops #1702

Open
@lishaduck

Description

@lishaduck

What input code did you provide to the formatter?

Column(
  children: [
    for (final CommentEntity(:comment, :timestamp, :authorName) in value.comments) ...[
      CircleAvatar(
        backgroundImage: MemoryImage(value.avatar),
      ),
      Text(authorName),
      Timeago(
        date: timestamp,
        builder: (context, value) => Text(value),
      ),
      Text(comment),
    ],
  ],
),

What output did the formatter produce?

Column(
  children: [
    for (final CommentEntity(
          :comment,
          :timestamp,
          :authorName,
        )
        in value.comments) ...[
      CircleAvatar(
        backgroundImage: MemoryImage(value.avatar),
      ),
      Text(authorName),
      Timeago(
        date: timestamp,
        builder: (context, value) => Text(value),
      ),
      Text(comment),
    ],
  ],
),

What output did you expect or want the formatter to produce?

I honestly don't know, but this is hard to read.

Maybe this?

Column(
  children: [
    for (
      final CommentEntity(
          :comment,
          :timestamp,
          :authorName,
      ) in value.comments
    ) ...[
      CircleAvatar(
        backgroundImage: MemoryImage(value.avatar),
      ),
      Text(authorName),
      Timeago(
        date: timestamp,
        builder: (context, value) => Text(value),
      ),
      Text(comment),
    ],
  ],
),

Anything else we should know?

Thanks!

^ You're welcome!

Uhh, this is inside of a deeply nested Flutter structure, that's why it's linebreaking so soon.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions