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.

Code formatting style

See original GitHub issue

Actual

Runs auto format and gets this crazy alignment with helper lines, see picture. BAD

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:closed
  • Created 4 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
giaur500commented, Apr 20, 2021

Problem is still not solved:

image

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.

1reaction
jacob314commented, May 7, 2019

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. repro Android Studio 3.4 version of the Flutter plugin. flutter-intellij.zip

Read more comments on GitHub >

github_iconTop 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 >

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