变更专案名称 [英] Changing the project name
问题描述
是否可以更改Flutter项目的项目名称?项目名称是指您在创建Flutter项目flutter create name
时提供的名称.
Is it possible changing the project name of a Flutter project? With project name I mean the name you provide when creating a flutter project flutter create name
.
推荐答案
这取决于您要实现的目标.如果要更改在手机菜单中显示的应用程序名称以及应用程序图标,则必须更改android/app/src/main/AndroidManifest.xml
(代码示例1)中的android:label
和<ios/Runner/Info.plist
(代码示例2).
That depends on what you are trying to achieve. If you want to change the name of the app which is displayed in the mobile phones menu together with the app icon, you have to change the android:label
in the android/app/src/main/AndroidManifest.xml
(Code Sample 1) and the CFBundleName
in the ios/Runner/Info.plist
(Code Sample 2).
上次执行此操作花了我很长时间才能找出原因,为什么未在Android上当前运行的应用程序列表中更改应用程序的名称.为此,您还需要更改MaterialApp的标题(代码示例3).
Last time I did this it took me ages to find out, why the name of the app was not changed in the list of currently running apps on Android. For that you also need to change the title of your MaterialApp (Code Sample 3).
为在任何地方重命名,我建议在项目中使用搜索和替换.如果这样做,则必须选择一个没有空格或特殊字符的名称.例如,pubspec.yaml
中的项目名称新项目"将破坏构建.
For renaming it everywhere I would suggest to use search and replace in the project. If you do this, you have to choose a name without spaces or special characters. A project name 'new project' in the pubspec.yaml
for example will break the build.
代码示例1:
<application
android:name="io.flutter.app.FlutterApplication"
android:label="New Name"
android:icon="@mipmap/ic_launcher">
代码示例2:
<key>CFBundleName</key>
<string>New Name</string>
代码示例3:
return new MaterialApp(
title: 'New Name'
...);
这篇关于变更专案名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!