Android Studio wrong auto indent for dart - android-studio

I am a newbie to Flutter and I am happy to try this great technology.
And I am going to try to follow this example https://medium.com/flutterpub/flutter-auth-with-google-f3c3aa0d0ccc to do a Google Sign in
Personally, I like to separate the chains of function call line by line instead of one line. It is like below:
_googleSignIn
.signInSilently()
.whenComplete(() => {
print("Login complete");
});
However, when I do the auto format in Android Studio for these dart code, it give me the result in the picture below.
It give me not only an ugly code formatting, but also a wrong feeling of the scope of function.
Is there any way can help me to solve this issue?

I think yours is an issue of trailing comma.
dartfmt actually uses trailing commas to determine when to go to the next line, and yours is missing one at the end of your code. Try reading this to understand why this is an issue.

Related

Does there any way that can make the autofill come out in android studio?

Does anyone know how to let the autofill thing come out whenever I want?
It is really frustrating that I have to retype my code so that the autofill thing will automatically come out, currently that is my way of doing it
I found it by myself. It is control + space and the Basic code completion will come out.
Also can use Control+Shift+Space and Smart code completion (filters the list of methods and variables by expected type) will come out
Check out other shortcut here!

VS Code Flutter shortcuts equivalent to Android Studio Flutter

I am looking for a few things to improve my productivity, Android Studio has these features and it really sped up my work, if you know any of these please share.
Ctrl+Shift+Space equivalent in VS Code Flutter. What it did in Android Studio was auto complete a statement. For example if I typed in if and then hit Ctrl+Shift+Space, the if condition code block would be completed for me automatically with () and {} after it, with putting the cursor within the condition.
Code snippets for things like for loops. On Android Studio you could type in iter and then Tab, it would create for (var _ in ) {} and automatically jump to both variables to fill their names on two Enter keystrokes.
These were great for me, please share if these exist in VS Code, as I understand it is supposed to be superior.
You should install dart extension for VSCode.
In order to prioritize the extension snippets and have these ones for the first suggestion, go to File/Settings/Text Editor/Suggestions and set Snippet Suggestions to top. Now it looks like

My VSCode intellisense is not prioritizing exact match , instead highlighting another method. How do I fix this?

Whenever I try to use a chain function, the intellisense sometimes suggests me something other than the exactly typed word first, which is weird.Here is the image of the issue
Help :)

How can I color the output in Logcat or Run in Android Studio?

Wanting to make some output in Logcat or Run more visible, I would like to color it.
But nothing worked, that I found on stackoverflow,
not the ANSI escape codes and
not even System.err.println("Color")!
(See e.g. this question)
Finally I tried: Log.e(TAG, "eeeee") // (TAG needs to be a String)
That worked! It was red.
(Note: Maybe try-catch blocks remove colors.)
But I would like to use more colors, too. Does anyone know how to do it?
Maybe the ANSI escape codes can be used, too. But how?
Looking forward to the answers!
Finally I got more color into my output!
The answers to this question gave me an idea, but did not solve the problem.
In the Preferences... of Android Studio the colors can be changed in Android Logcat. The problem was, that most color values were inherited from the standard output. This needs to be unchecked. Then the colors can be freely changed. And it works!
Now I can use Log.i(...), Log.v(...), Log.w(...), Log.d(...), Log.e(...) in the Java code to get different colors in the output.

Android Studio -- code completion order screwy?

Can anybody tell me if there's a way to modify Android Studio's presentation order for code completion?
Writing Dart / Flutter code and whenever I want to print() something to the console, the print() function is second in the list (behind Icons.print, of all freaking things) and I am constantly forgetting and having to undo and step down one place in the list.
It's terribly inconvenient and frustrating. There is another example that constantly drives me batty too, but I cannot remember what it is right now. Would be wonderful if there were a way to modify this in some way.
Thank you in advance, for saving my sanity!

Resources