skip to Main Content

I’m writing flutter app, and I have this block of dart code

  Widget launchScreen() {
    return Screen(
        child: Container(
            color: Colors.lightBlue,
            child: Center(
                child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Container(
                          height: 200, 
                          width: 200, 
                          child: Image.asset("resources/images/logo.png")
                      ),
                    ]
                )
            )
        )
    );
  }

which seems very neat and well indented, but after running Reformat Code in Android Studio, the result is so ugly and stupid

  Widget launchScreen() {
    return Screen(
        child: Container(
            color: Colors.lightBlue,
            child: Center(
                child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
              Container(height: 200, width: 200, child: Image.asset("resources/images/logo.png")),
            ]))));
  }

I tried to update the code style for dart in the settings but I can’t find any options to be customized only the line width.

is there a way to improve(fix) the formatting?

2

Answers


  1. Dart format use the , has parameter

    Screen(
      child: Container(
        color: Colors.lightBlue,
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Container(
                height: 200,
                width: 200,
                child: Image.asset("resources/images/logo.png"),
              ),
            ],
          ),
        ),
      ),
    );
    
    Login or Signup to reply.
  2. Try to add , after ] and )
          
       Widget launchScreen() {
        return Screen(
          child: Container(
            color: Colors.lightBlue,
            child: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Container(
                    height: 200,
                    width: 200,
                    child: Image.asset(
                      "resources/images/logo.png",
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search