Skip to content

Code formatting style  #3455

@harounhajem

Description

@harounhajem

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions