Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dart 3.7] Shorter code creates more lines #1605

Open
passsy opened this issue Nov 28, 2024 · 0 comments
Open

[Dart 3.7] Shorter code creates more lines #1605

passsy opened this issue Nov 28, 2024 · 0 comments

Comments

@passsy
Copy link

passsy commented Nov 28, 2024

Hey Bob,

Some feedback on the new proposed style for Dart 3.7. I tested it with my spot package and found this interesting case I can't explain. It looks like a bug to me.

Before

unformatted, does not fit within 80 characters

void main() {
  testWidgets('sometest', (tester) async {
    final appBar = spot<AppBar>();
    
    appBar.spotIcon(Icons.settings, parents: [spot<IconButton>()]).doesNotExist();

    appBar.spotIcon(Icons.home, parents: [spot<IconButton>()]).existsExactlyNTimes(2);
  });
}

Actual

// Formatted with Dart 3.5
void main() {
  testWidgets('sometest', (tester) async {
    final appBar = spot<AppBar>();

    appBar
        .spotIcon(Icons.settings, parents: [spot<IconButton>()]).doesNotExist();

    appBar.spotIcon(Icons.home,
        parents: [spot<IconButton>()]).existsExactlyNTimes(2);
  });
}
// Formatted with Dart 3.7 (--git-ref=flutter-style-experiment)
void main() {
  testWidgets('sometest', (tester) async {
    final appBar = spot<AppBar>();

    appBar.spotIcon(
      Icons.settings,
      parents: [spot<IconButton>()],
    ).doesNotExist();

    appBar
        .spotIcon(Icons.home, parents: [spot<IconButton>()])
        .existsExactlyNTimes(2);
  });
}

What's unclear is why the first appBar.spotIcon line creates 4 LOC, whereas the second only requires 3.

It is possible to format the first line, like the second, without any problem. Why do they behave differently?

Expected

void main() {
  testWidgets('sometest', (tester) async {
    final appBar = spot<AppBar>();

    appBar
        .spotIcon(Icons.settings, parents: [spot<IconButton>()])
        .doesNotExist();

    appBar
        .spotIcon(Icons.home, parents: [spot<IconButton>()])
        .existsExactlyNTimes(2);
  });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant