question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android studio reformat code has variants

See original GitHub issue

Steps to Reproduce

I am using Android studio for my Flutter/Dart project, I use Code->Reformat Code or Ctrl+Alt+L to reformat my code I also checked Before commit -> Reformat code in settings

When I commit my code, it is reformatted by android studio automatically, But after that if I press Ctrl+Alt+L to reformat it again, it reformatted with different rules , If I commit it immediately, auto reformat before commit revert changes and we have nothing to commit

Version info

[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.18363.1198], locale en-US)
    • Flutter version 1.22.4 at C:\flutter
    • Framework revision 1aafb3a8b9 (2 weeks ago), 2020-11-13 09:59:28 -0800
    • Engine revision 2c956a31c0
    • Dart version 2.10.4


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\PC\AppData\Local\Android\Sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = C:\Users\PC\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[!] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] Connected device (1 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

! Doctor found issues in 1 category.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jacob314commented, Nov 30, 2020

It is unfortunate that the before commit command is using the wrong code formatter for dart code. Here is a workaround until we get that code fixed to use Dartfmt.

To use dartfmt to reformat code on save you can enable it under the Flutter settings in IntelliJ. It is confusing that Screen Shot 2020-11-30 at 8 31 19 AM

@jwren is this a known issue is the dart intelliij plugin?

0reactions
alexander-doroshkocommented, Dec 2, 2020

Thanks, I’ve filed an issue in the Dart plugin’s issue tracker and fixed it. The Dart plugin update with the fix will be published in a few days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling design variants - Android Developers
In Figma, variants are used to group different variations of the same component together, such as different states or sizes.
Read more >
IntelliJ IDEA: how to revoke reformat code / optimize imports ...
In current versions of IntelliJ (and likely Android studio and other IntelliJ based IDEs) there no longer seems to be this option as...
Read more >
Android Studio 4.1: google-java-format option not ... - GitHub
I upgraded from Android Studio 4.0 to 4.1 and the google-java-format plugin seemed to stop working. At first, it was because all my...
Read more >
11 Android Studio Shortcuts every Android Developer must ...
Just Press CTRL+ALT+L on Windows or Command+Option+L on Mac. The android studio will reformat all the code for you. And the good part...
Read more >
Code Formatting | The IntelliJ IDEA Blog
We can go into the preferences and set our expected standards. In Editor -> Code Style -> Java (for our case), we'll see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found