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

[Formatting issue] Line breaks don't feel right #1739

@eli1stark

Description

@eli1stark

We ran a new formatter on our codebase with trailing commas preserved. Here are a couple of cases where the line breaks don’t feel natural to us.

What input code did you provide to the formatter?

// case 1
_barrierOpacity = Tween<double>(
  begin: 0,
  end: 0.8,
).animate(
  CurvedAnimation(
    parent: _controller,
    curve: Curves.easeOutCubic,
  ),
);

// case 2
Animation<double> _animation() {
  return TweenSequence<double>([
    TweenSequenceItem(
      weight: 20,
      tween: Tween<double>(
        begin: 1,
        end: 1.1,
      ).chain(
        CurveTween(
          curve: const Cubic(0.2, 0, 0.4, 1),
        ),
      ),
    ),
  ]).animate(_controller);
}

// case 3
typedef ConditionalWrapperBuilder = Widget Function(
  BuildContext context,
  Widget child,
);

// case 4 (declare argument of the class)
final Widget Function(
  BuildContext context,
  double shrinkOffset,
  bool overlapsContent,
) builder;

// case 5 (no strong opinion on this one)
description: 'We were unable to verify your account. Please try '
    'again or use a different sign-in method.',

What output did the formatter produce?

// case 1
_barrierOpacity =
    Tween<double>(
      begin: 0,
      end: 0.8,
    ).animate(
      CurvedAnimation(
        parent: _controller,
        curve: Curves.easeOutCubic,
      ),
    );

// case 2
Animation<double> _animation() {
  return TweenSequence<double>([
    TweenSequenceItem(
      weight: 20,
      tween:
          Tween<double>(
            begin: 1,
            end: 1.1,
          ).chain(
            CurveTween(
              curve: const Cubic(0.2, 0, 0.4, 1),
            ),
          ),
    ),
  ]).animate(_controller);
}

// case 3
typedef ConditionalWrapperBuilder =
    Widget Function(
      BuildContext context,
      Widget child,
    );

// case 4 (declare argument of the class)
final Widget Function(
  BuildContext context,
  double shrinkOffset,
  bool overlapsContent,
)
builder;

// case 5 (no strong opinion on this one)
description:
    'We were unable to verify your account. Please try '
    'again or use a different sign-in method.',

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

// case 1
_barrierOpacity = Tween<double>(
  begin: 0,
  end: 0.8,
).animate(
  CurvedAnimation(
    parent: _controller,
    curve: Curves.easeOutCubic,
  ),
);

// case 2
Animation<double> _animation() {
  return TweenSequence<double>([
    TweenSequenceItem(
      weight: 20,
      tween: Tween<double>(
        begin: 1,
        end: 1.1,
      ).chain(
        CurveTween(
          curve: const Cubic(0.2, 0, 0.4, 1),
        ),
      ),
    ),
  ]).animate(_controller);
}

// case 3
typedef ConditionalWrapperBuilder = Widget Function(
  BuildContext context,
  Widget child,
);

// case 4 (declare argument of the class)
final Widget Function(
  BuildContext context,
  double shrinkOffset,
  bool overlapsContent,
) builder;

// case 5 (no strong opinion on this one)
description: 'We were unable to verify your account. Please try '
    'again or use a different sign-in method.',

Anything else we should know?

Thank you for your hard work!

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