在开发过程中我们习惯给新建的类添加一些注释信息,创建日期、时间和作者等。但是flutter中新建的dart文件默认是没有这些备注信息的,属于手动添加Templates
步骤如下:
一、Android Studio -> Preferences -> Editor ->File and Code Templates
001.pngFile -> New -> Edit File Templates
二、选中Files标签页,点击+号,Name栏输入StatelessWidget,下面的输入框输入以下代码
class ${NAME} extends StatelessWidget {
}
002.png
设置Dart File的文件模板为
//
// ${NAME}
// ${PROJECT_NAME}
//
// Created by ${USER} on${DATA} .
// Copyright ©${DATA} ${PROJECT_NAME}. All rights reserved.
//
003.png
Tips: 添加更多的注释信息可查看下面的描述
Predefined variables will take the following values:
${PACKAGE_NAME}
name of the package in which the new file is created
${NAME}
name of the new file specified by you in the New <TEMPLATE_NAME> dialog
${USER}
current user system login name
${DATE}
current system date
${TIME}
current system time
${YEAR}
current year
${MONTH}
current month
${MONTH_NAME_SHORT}
first 3 letters of the current month name. Example: Jan, Feb, etc.
${MONTH_NAME_FULL}
full name of the current month. Example: January, February, etc.
${DAY}
current day of the month
${DAY_NAME_SHORT}
first 3 letters of the current day name. Example: Mon, Tue, etc.
${DAY_NAME_FULL}
full name of the current day. Example: Monday, Tuesday, etc.
${HOUR}
current hour
${MINUTE}
current minute
${PROJECT_NAME}
the name of the current project
网友评论