IntelliJ indents } the same as the contents between { and }

186 Views Asked by At

I'm using IntelliJ and the Dart plugin (version 213.5744.122), and for some reason IntelliJ insists on creating a weird indentation in the following code:

Expanded(
  child: TextFormField(
    decoration: InputDecoration(labelText: 'CA', border: OutlineInputBorder(),),
    controller: caController,
    onChanged: (_){
      setState((){});
      },
    enabled: true,
  ),
),

Notice how the closing } of the onChanged handler is indented one step further in than a sane person would put it. Personally, I would normally unindent the } one step. If that's not possible for some reason, as a very last resort I would at least indent the contents between { and } one step further than the }. But IntelliJ insists on indenting both the content and the } equally.

If I try running Reformat code with dart format on the code, it fixes the indentation. So it seems to be a problem with IntelliJ, not the Dart formatter?

Also, if I completely remove any contents between { and } like this

onChanged: (_){}

and then place the cursor between { and } and hit Enter, it formats it correctly:

onChanged: (a){

},

How can I fix this?? There are no code style settings available for Dart in the IntelliJ settings, so what can I do?

0

There are 0 best solutions below