我已经使用名为rename的包更改了我的应用程序名称,并成功更改了它,但我可以在文件pubspec.yaml中看到文件中的第一个参数如下:

name: oldname

Pubspec.yaml中的这个参数会对应用程序产生影响吗?

我还有包裹,地址写在我图书馆的每一页上,如下所示:

import 'package:oldname/Pages/BasePage.dart';
import 'package:oldname/Globals.dart';

我如何将这里的旧名字改为新名字,我应该怎么做?或者这不会影响实际显示的任何内容?

推荐答案

Pubspec.yaml文件中的名称参数用于指定Flutter 项目或包的名称.它是必填字段,在DART程序包存储库中必须是唯一的.

如果更改pubspec.yaml中的名称参数,则还需要将语句从

import 'package:oldname/Pages/BasePage.dart';
import 'package:oldname/Globals.dart';

import 'package:newn_name/Pages/BasePage.dart';
import 'package:new_name/Globals.dart';

If you want 至 rename your project, I recommend you 至 use this package https://pub.dev/packages/rename It will change app name. Then you can rename the 'name' in pubspec.yaml and then change all the import statements with find and replace It's not manda至ry but it's good 至 change it 至 the name of your app. Here is how you can easily change it with find and replace 至ol.

  1. Press Ctrl + Shift + R (Windows/Linux) or Cmd + Shift + R (Mac) 至 open the "Find and Replace in Path" dialog.

  2. 在"Find"字段中,输入旧的应用程序名称(例如,IMPORT‘Package:old_app_name).

  3. 在"替换为"字段中,输入新的应用程序名称(例如,IMPORT‘Package:new_app_name).

Make sure the "File mask" field is set 至 *.dart 至 search only in Dart files.

  1. Choose the "Direc至ry" scope and ensure that the root direc至ry of your project is selected.

  2. Click on the "Find" but至n 至 show the search results.

  3. 查看更改,如果一切正常,请单击全部替换.

Flutter相关问答推荐

Riverpod生成器和生成util类

Flutter Go路由深度链接不按预期工作

什么是dart :这只是dart ?

如何在抖动中预加载一条路由,或者即使在屏幕外也保持加载小工具?

Flutter :执行com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction时出现故障

为什么用户界面不会在Flight中的复选框中更改?

Flutter Android Google Sign-in error:ApiException:10在确认软件包名称、SHA-1 fingerprint 和设置同意页面后出现异常

不要跨同步间隔使用BuildContext

带有附加图像的ListTile

不使用 GlobalKey 仍然收到 GlobalKey 被多次使用的错误

启动画面中的淡入淡出图像

如何在 GridView.builder 中设置 textform 字段并在 flutter 中将 12 个 textformfield 作为单个字符串获取?

flutter 中 // 和 /// 有什么区别

对话框打开时如何使背景模糊?

通过点击缩略图加载全屏图像

在 Flame Forge2d 中射击子弹

Flutter RawMaterialButton 常量相对大小

Flutter:如何判断嵌套列表是否包含值

根据索引/变量更改小部件的 colored颜色

解密 Modulr 安全令牌