gpt4 book ai didi

dart - 为什么标签缩进在 VSCode 中不一致? ( Dart 语言)

转载 作者:行者123 更新时间:2023-12-03 04:00:11 44 4
gpt4 key购买 nike

我想问一下“格式文档”功能,为什么在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_style/dartfmt 完成,它的约定是 2 个空格缩进,用 4 spaces for continued lines .

对于 Flutter 代码,这通常不是最佳格式,因此可以使用尾随逗号稍微更改格式以使其效果更好:

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

关于dart - 为什么标签缩进在 VSCode 中不一致? ( Dart 语言),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57863993/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com