我有此代码:
void main() {
print('Hello!');
runApp(
MaterialApp(
home: Container(color: Colors.greenAccent)
)
);
}
重新格式化此代码后,它变为:
void main() {print('Hello!');runApp(MaterialApp(home:Container(color:Colors.greenAccent)));
}
我想要:
void main() {
print('Hello!');
runApp(
MaterialApp(
home: Container(color: Colors.greenAccent)
)
);
}
我该如何重新格式化?
答案 0 :(得分:2)
像下面的示例一样添加尾随逗号:https://flutter.dev/docs/development/tools/formatting
因此您的代码将变为:
void main() {
print('Hello!');
runApp(
MaterialApp(
home: Container(color: Colors.greenAccent), , // <----- comma
), // <----- comma
);
}