dart-lang / dart_style

An opinionated formatter/linter for Dart code
https://pub.dev/packages/dart_style
BSD 3-Clause "New" or "Revised" License
645 stars 118 forks source link

This indentation is very unsightly #1441

Closed niuxinyu closed 1 month ago

niuxinyu commented 5 months ago

This is the test code

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
        child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        const Text('你好'),
      ],
    ));
  }
}

and this is what it looks like

image

At the position of the Row component, the line break is not quite right,i think Maybe it should look something like this?

image

And ,this is what it looks like in android studio

image
munificent commented 4 months ago

I agree, the output is not great here. Output like this is one of the reasons why we're rewriting the formatter and moving to a new style (#1253). With the new in-progress style, the output looks like:

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
        const Text('你好'),
      ]),
    );
  }
}
munificent commented 1 month ago

Since the new formatter does a good job on this code and we're planning to move to that, I'm going to go ahead and close this.