【发布时间】:2020-01-07 02:10:42
【问题描述】:
谁能向我解释为什么 dart 以它的方式格式化代码? 我安装了 dart 插件并使用了“Dart:使用推荐的设置”。
Future<void> addProduct(Product product) {
return http
.post(
'$url.json',
body: json.encode(
{
'title': product.title,
'description': product.description,
'imageUrl': product.imageUrl,
'price': product.price,
'isFavorite': product.isFavorite,
},
),
)
.then((response) {
var id = json.decode(response.body)['name'];
var newProduct = Product(
description: product.description,
title: product.title,
price: product.price,
imageUrl: product.imageUrl,
id: id,
);
_items.add(newProduct);
notifyListeners();
}).catchError((err) {});
}
【问题讨论】:
-
插件很可能使用dartfmt(我认为插件不会在内部格式化您的代码)
标签: flutter dart visual-studio-code formatting