如何为我的Flutter Web应用程序配置图标?

时间:2019-06-25 00:53:47

标签: flutter

我正在尝试使用Flutter for Web,但找不到有关如何配置图标的信息。

应该有可能,因为taphero_web以某种方式做到了。我查看了他们的消息来源,但找不到该站点的图像:

enter image description here

我使用codemagic.io托管我的应用程序。 有什么想法吗?

3 个答案:

答案 0 :(得分:3)

我开始按照Mariano Zorilla的回答中的说明进行操作,但发现如果只想为Flutter Web App设置Favicon,它会更简单。

  1. 在创建图标的网站like the one Mariano suggested中上传图片。
  1. 选择“仅生成16x16 favicon.ico”选项并下载图标文件。

  2. 将favicon.ico放置在您的Web目录中(其中index.html和flutter的默认favicon.png所在)

  3. 在您的index.html文件中...

替换:

<link rel="shortcut icon" type="image/png" href="favicon.ico"/>

具有:

<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">

答案 1 :(得分:2)

很高兴你问!作为该项目的所有者,我可以告诉您我是如何做到的:

1-在要推送到服务器的文件夹内,添加/ icons文件夹。

2-到达那里后,您需要使用this one之类的网站上传一组图像。

3-看起来像这样:

Icons Folder

4-您的manifest.json看起来像这样:

{
    "short_name": "Tap Hero",
    "name": "Tap Hero",
    "icons": [
        {
            "src": "\/icons/android-icon-36x36.png",
            "sizes": "36x36",
            "type": "image\/png",
            "density": "0.75"
        },
        {
            "src": "\/icons/android-icon-48x48.png",
            "sizes": "48x48",
            "type": "image\/png",
            "density": "1.0"
        },
        {
            "src": "\/icons/android-icon-72x72.png",
            "sizes": "72x72",
            "type": "image\/png",
            "density": "1.5"
        },
        {
            "src": "\/icons/android-icon-96x96.png",
            "sizes": "96x96",
            "type": "image\/png",
            "density": "2.0"
        },
        {
            "src": "\/icons/android-icon-144x144.png",
            "sizes": "144x144",
            "type": "image\/png",
            "density": "3.0"
        },
        {
            "src": "\/icons/android-icon-192x192.png",
            "sizes": "192x192",
            "type": "image\/png",
            "density": "4.0"
        }
    ]
}

5-完成所有操作后,将其余图标添加到index.html内:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="description" content="Tap Hero">
    <meta name="keywords" content="Flutter, Tap, Hero, Game">
    <meta name="author" content="Mariano Zorrilla">
    <meta name="theme-color" content="#6200EA" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="apple-touch-icon" sizes="57x57" href="icons/apple-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="icons/apple-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="icons/apple-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="icons/apple-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="icons/apple-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="icons/apple-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="icons/apple-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="icons/apple-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="icons/apple-icon-180x180.png">
    <link rel="icon" type="image/png" sizes="192x192" href="icons/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="96x96" href="icons/favicon-96x96.png">
    <link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png">
    <link rel="manifest" href="icons/manifest.json">
    <meta name="msapplication-TileColor" content="#6200EA">
    <meta name="msapplication-TileImage" content="icons/ms-icon-144x144.png">
    <title>Tap Hero</title>
    <script defer src="main.dart.js" type="application/javascript"></script>
</head>

<body>
</body>
</html>

答案 2 :(得分:2)

要将您的收藏夹图标配置为颤动的网络,只需将路径./web/favicon.png上的文件替换为您自己的图标,然后运行flutter build web