Code formatting style
See original GitHub issueActual
Runs auto format and gets this crazy alignment with helper lines, see picture.
Expected
Runs auto format and gets helper lines that align properly.
Steps to Reproduce
Run auto format with “Reformat code with Dart fmt” or “Reformat code”, on this code:
class _MyHomePageState extends State<MyHomePage> {
int numTaps = 0, numDoubleTaps = 0, numLongPress = 0;
double posX = 0.0, posY = 0.0, boxSize = 150.0;
@override
Widget build(BuildContext context) {
if (posX == 0) {
setCenter(context);
}
return Scaffold(
appBar: AppBar(
title: Text("Gestures and Animations"),
),
bottomNavigationBar: Material(
color: Theme.of(context).primaryColorLight,
child: Padding(
padding: EdgeInsets.all(15),
child: Center(
heightFactor: 1,
child: Text(
"Taps: $numTaps - Double taps: $numDoubleTaps - Longpress: $numLongPress",
style: TextStyle(color: Colors.black, fontSize: 18))),
),
),
body: GestureDetector(
onTap: () {
setState(() {
numTaps++;
});
},
onDoubleTap: () {
setState(() {
numDoubleTaps++;
});
},
onLongPress: () {
setState(() {
numLongPress++;
});
},
child: Stack(
children: <Widget>[
Positioned(
top: posY,
left: posX,
child: Container(
width: boxSize,
height: boxSize,
decoration: BoxDecoration(color: Colors.orangeAccent),
))
],
),
),
);
}
void setCenter(BuildContext context) {
posX = (MediaQuery.of(context).size.width / 2 - boxSize / 2);
posY = (MediaQuery.of(context).size.height / 2 -
boxSize / 2 -
80 /*Top- and bottom-size*/);
setState(() {
posX = posX;
posY = posY;
});
}
}
This issue happens more and more often and is very distracting.
Version info
Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17763.475], locale en-GB) Android toolchain - develop for Android devices (Android SDK version 28.0.3) Android Studio (version 3.4) Flutter plugin 35.1 Dart v.183.6270
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Code Style and Formatting - The Turing Way
A coding style is a set of conventions on how to format code. For instance, what do you call your variables? Do you...
Read more >Why Coding Style Matters - Smashing Magazine
Coding style is a lot like that. You are defining the equivalent of spelling and grammar rules for everyone to follow. Your style...
Read more >Google Style Guides | styleguide
Style guides for Google-originated open-source projects. ... This project (google/styleguide) links to the style guidelines we use for Google code.
Read more >Code style and formatting | IntelliJ IDEA Documentation
IntelliJ IDEA helps you maintain the required code style by formatting your code for you according to the code style rules. IntelliJ IDEA...
Read more >Formatting (GNU Coding Standards)
5.1 Formatting Your Source Code. Please keep the length of source lines to 79 characters or less, for maximum readability in the widest...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Problem is still not solved:
https://github.com/dart-lang/dart_style/issues/1021
Still crazy ouput with broken guide outlines. I don’t know what is to fix - formatting or outlines generating.
With 35.2 you may still see a flicker of strange indent guides after the format. In the next release we will fix the flicker of strange indents as well. Here’s a beta plugin you can try to verify it helps. With the beta plugin at worst you will see a few indent guides temporarily disappear on code format until a new valid “Flutter Outline” is computed. Android Studio 3.4 version of the Flutter plugin. flutter-intellij.zip