【问题标题】:Why Tab Indent is not Consistent in VSCode ? (Dart Language)为什么制表符缩进在 VSCode 中不一致? (飞镖语言)
【发布时间】:2020-01-11 19:26:12
【问题描述】:

我想问一下“格式化文档”功能,为什么在VScode中使用“文档格式”功能时,表格会变得像我下面附加的代码一样不规则。

我尝试将“编辑器:标签大小”设置为 2,但是当我使用“格式化文档”时,我的代码变得不规则。

@override
Widget build(BuildContext context) {
````return new Container(
````````child: new Column(
``````children: <Widget>[
````````new Row(
``````````children: <Widget>[
````````````//slideshow
````````````new Expanded(
````````````````child: new CarouselSlider(
``````````````height: 150.0,

我希望这样的代码:

@override
``Widget build(BuildContext context) {
````return new Container(
``````child: new Column(
````````children: <Widget>[
``````````new Row(
````````````children: <Widget>[
``````````````//slideshow
``````````````new Expanded(
````````````````child: new CarouselSlider(
````````````````height: 150.0,

【问题讨论】:

    标签: dart visual-studio-code vscode-settings


    【解决方案1】:

    格式由dart_style/dartfmt完成,约定为2空格缩进,4 spaces for continued lines

    对于 Flutter 代码,这通常不是最好的格式,所以可以使用尾随逗号来稍微改变格式,效果更好:

    https://flutter.dev/docs/development/tools/formatting#using-trailing-commas

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-26
      • 2019-10-24
      • 2022-02-03
      • 2021-02-16
      • 2019-02-05
      • 2019-06-11
      • 1970-01-01
      相关资源
      最近更新 更多