这是indexloc提供的服务,不要输入任何密码
Skip to content

[Formatting issue] => expression containing a method call chain #1705

@chris-NR

Description

@chris-NR

What input code did you provide to the formatter?
This is the output produced by the earlier (<= 3.6) formatter

class StatePanelX extends StatelessWidget {
  const StatePanelX({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<MachineBloc, MachineState>(
      buildWhen: (previous, current) => current.status != previous.status,
      builder: (context, state) {
        return Row(children: [
          state.status.isRefreshable
              ? IconButton(
                  color: Colors.amber,
                  onPressed: () => context
                      .read<MachineBloc>()
                      .add(WeatherRefreshRequested()),
                  icon: const Icon(Icons.restart_alt),
                )
              : const IconButton(
                  color: Colors.grey,
                  onPressed: null,
                  icon: Icon(Icons.restart_alt),
                ),
          StatusIndicator(status: state.status),
        ]);
      },
    );
  }
}

What output did the formatter produce?

class StatePanelX extends StatelessWidget {
  const StatePanelX({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<MachineBloc, MachineState>(
      buildWhen: (previous, current) => current.status != previous.status,
      builder: (context, state) {
        return Row(
          children: [
            state.status.isRefreshable
                ? IconButton(
                  color: Colors.amber,
                  onPressed:
                      () => context.read<MachineBloc>().add(
                        WeatherRefreshRequested(),
                      ),
                  icon: const Icon(Icons.restart_alt),
                )
                : const IconButton(
                  color: Colors.grey,
                  onPressed: null,
                  icon: Icon(Icons.restart_alt),
                ),
            StatusIndicator(status: state.status),
          ],
        );
      },
    );
  }
}

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

See the first example above. The problem seems to occur due to the auto-inserted comma after WeatherRefreshRequested()

Anything else we should know?

This issue was originally raised as part of #1668

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