簡體   English   中英

Dart 格式在 vscode 中很奇怪

[英]Dart format is weird in vscode

我的 dart 文件格式奇怪

    return Scaffold(
        backgroundColor: bgColor,
        body: SafeArea(
            child: Container(
          decoration: BoxDecoration(
              image: DecorationImage(
                  image: AssetImage('assets/$bgImage'), fit: BoxFit.cover)),
          child: Padding(
            padding: const EdgeInsets.fromLTRB(0, 120, 0, 0),
            child: Column(
              children: <Widget>[
                FlatButton.icon(

如何進行設置,以便正常的小部件樹可以正確縮進。

另外,我設置了“editor.rulers”:[120],這仍然給了我不想要的自動縮進:

                    onPressed: () async {
                      **dynamic result =
                          await Navigator.pushNamed(context, '/location');**
                      setState(() {
                        data = {
                          'time': result['time'],
                          'location': result['location'],
                          'flag': result['flag'],
                          'isDaytime': result['isDaytime']
                        };
                      });
                    },

在 arguments 列表中使用尾隨逗號。

沒有尾隨逗號:

Foo(arg1: ..., arg2: ...)

尾隨逗號:

Foo(
  arg1: ...,
  arg2: ..., // notice the comma
)

例如:

decoration: BoxDecoration(
  image: DecorationImage(
    image: AssetImage('assets/$bgImage'), 
    fit: BoxFit.cover, // add a comma here
  ), // add a comma here
),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM