Skip to content

[Formatting issue] Weird indentation when method chains are called on Widgets #1770

@oppahansi

Description

@oppahansi

What input code did you provide to the formatter?

Example 1:

return Tooltip(
  message: tooltipMessage,
  child: Image.asset(
    imagePath,
    width: width,
    height: width,
    fit: BoxFit.cover,
    color: imageColor,
    colorBlendMode: BlendMode.saturation,
    errorBuilder: (context, error, stack) =>
        const Icon(Icons.error),
  )
  .container(
    decoration: BoxDecoration(
      border: Border.all(color: borderColor, width: 2.0),
      borderRadius: BorderRadius.circular(8.0),
    ),
  )
  .gestureDetector(
    onTap: enabled ? () => buildNotifier.addPoint(talent) : null,
    onLongPress: () {
      _showTalentDetailSheet(context, ref, talent);
    },
  ),
);

Example 2:

[
  "${widget.tree.names[settings.locale.languageCode]} ($pointsInTree)"
      .text(style: bodySmall(context).withColor(classColor)),

  spentPointState.text(
    style: bodySmall(context).withColor(classColor),
  ),
]
.row(mainAxisAlignment: MainAxisAlignment.spaceEvenly)
.container(
  decoration: BoxDecoration(color: Colors.black.withAlpha(100)),
)
.paddingAll(gapSizeSmall(context));

What output did the formatter produce?

Output Example 1:

return Tooltip(
  message: tooltipMessage,
  child:
      Image.asset(
            imagePath,
            width: width,
            height: width,
            fit: BoxFit.cover,
            color: imageColor,
            colorBlendMode: BlendMode.saturation,
            errorBuilder: (context, error, stack) =>
                const Icon(Icons.error),
          )
          .container(
            decoration: BoxDecoration(
              border: Border.all(color: borderColor, width: 2.0),
              borderRadius: BorderRadius.circular(8.0),
            ),
          )
          .gestureDetector(
            onTap: enabled ? () => buildNotifier.addPoint(talent) : null,
            onLongPress: () {
              _showTalentDetailSheet(context, ref, talent);
            },
          ),
);

Output Example 2:

[
      "${widget.tree.names[settings.locale.languageCode]} ($pointsInTree)"
          .text(style: bodySmall(context).withColor(classColor)),

      spentPointState.text(
        style: bodySmall(context).withColor(classColor),
      ),
    ]
    .row(mainAxisAlignment: MainAxisAlignment.spaceEvenly)
    .container(
      decoration: BoxDecoration(color: Colors.black.withAlpha(100)),
    )
    .paddingAll(gapSizeSmall(context));

What output did you expect or want the formatter to produce?
I expected the formatter to not indent the code / the chain method calls so far to the right.

Anything else we should know?
I am using the exui package which provides the chainable utility methods you see above. Here container, gestureDetector, text, row, padding, container

Thanks!

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