简体   繁体   English

VS 代码:格式文档在 Flutter 上工作异常

[英]VS Code : Format document is working weird on Flutter

When i click "Format Document" button inside of page, it looks like this,当我点击页面内的“格式化文档”按钮时,它看起来像这样,

在此处输入图像描述

From what I can tell, you are trying to solve the awkward line wrapping and deep nesting problem.据我所知,您正在尝试解决尴尬的换行和深度嵌套问题。 When your code gets nested as deep as it is, it hits the column word wrap limit and the limit forces forces the formatter to break items that would normally be on one line into several.当您的代码嵌套尽可能深时,它会达到列自动换行限制,并且限制会强制格式化程序将通常在一行上的项目分解为多个。 There are a couple things you can do:您可以做几件事:

  1. Best option : Refactor your code and split it into multiple classes/ files.最佳选择:重构您的代码并将其拆分为多个类/文件。 That will make it so that you don't have as deeply nested code and it will make it more readable as well as more maintainable.这将使您没有那么深的嵌套代码,并且它将使其更具可读性和可维护性。
  2. Go to the vs code settings and search for Dart: Line Length and edit the value to set when the file starts wrapping content. Go 到 vs 代码设置并搜索Dart: Line Length并编辑文件开始包装内容时要设置的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM