Skip to content

JetBrains code formatter should use dartfmt #51911

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

Closed
johnpryan opened this issue Mar 30, 2023 · 4 comments
Closed

JetBrains code formatter should use dartfmt #51911

johnpryan opened this issue Mar 30, 2023 · 4 comments

Comments

@johnpryan
Copy link
Contributor

I've been using the default JetBrains formatter without realizing it, and there are cases where it tries to format the code even though it is invalid Dart code. I'd prefer if the "Format code" action used dartfmt instead.

Steps to reproduce:

  1. Run flutter create --empty new_project
  2. Open project in Android Studio / IntelliJ
  3. Delete the closing paren for the Scaffold widget:
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('Hello World!'),
        ),
      ,
    );
  }
}
  1. Run the "Reformat Code" action (not "Reformat code with dartfmt")
  2. Observe weird output:
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp
    (
        home: Scaffold(
    body: Center(
    child: Text('Hello World!'),)
    ,
    ,
    );
  }
}
@srawlins
Copy link
Member

Well, I guess that's a bug for JetBrains 😄 @stevemessick do you know where this should be directed?

@stevemessick
Copy link
Contributor

I thought @alexander-doroshko had changed everything to use dartfmt years ago. But no, I can reproduce this problem.

Ideally, there would be an issue on https://youtrack.jetbrains.com to track this. @jwren might find this interesting, too.

@alexander-doroshko
Copy link

Thanks, it's already tracked in YouTrack. Some details here and here. Sorry for the delay with these issues.

@srawlins
Copy link
Member

srawlins commented Apr 3, 2023

Thanks @stevemessick and @alexander-doroshko . Closing here.

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

4 participants