如何根据口味更改Flutter应用名称? [英] How to change Flutter app name depending on flavor?

查看:82
本文介绍了如何根据口味更改Flutter应用名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Flutter应用程序有开发和生产的经验.

I have development and production flavor for Flutter app.

问题是开发和生产应用程序的标签和启动器都相同,因此看不到差异.(实际上不能同时在设备上同时安装两者)

Issue is label and launcher are same for both development and production app so cannot see difference. (Actually cannot install both on device at same time)

根据口味更改Flutter应用名称的简单方法是什么?

What is simple way to change Flutter app name depending on flavor?

我知道可以通过修改AndroidManifest.xml和Xcode info.plist来更改应用程序标签和启动器.但这并不简单:必须在xml和plist文件中添加其他文件以供参考.像这样进行修改违反了Flutter的目标.

I know can change app label and launcher by modify AndroidManifest.xml and Xcode info.plist. But this not simple: must make additional file for reference in xml and plist file. Modify like this is against aim of Flutter.

有人知道解决方案吗?

谢谢!

推荐答案

只需在android项目 app gradle 中使用它:

Simply have this in android project app gradle :

flavorDimensions "default"
productFlavors {
    dev {
        resValue "string", "app_name", "AppName_DEV"
    }
    demo {
        resValue "string", "app_name", "AppName_Demo"
    }

    prod {
        resValue "string", "app_name", "AppName"
    }
}

,然后在您的 AndroidManifest 中使用此方法:

and then in your AndroidManifest just use this :

android:label="@string/app_name"

它将生成未解析的 app_name ,并且已完成!

it will generate unResolved app_name and it's done!

这篇关于如何根据口味更改Flutter应用名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆