如何为扑朔迷离的Web应用程序设置标题和图标? [英] How can you set title and icon for a flutter web app?
问题描述
我要做的是构建一个Flutter Web应用程序,当在浏览器中显示该选项卡时,该选项卡将显示一个图标和一个标题(目前,它仅显示世界图标和localhost ...标题).
What I'm trying to do is build a flutter web app that, when displayed in the browser, the tab shows an icon and a title (as currently it only shows the world icon and the localhost... title).
实际结果:
所需结果:
我现在可以添加标题了,因为它是在主函数中设置的
I can now add the title, as this is set in the main function
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: Icon(Icons.menu, color: Colors.white,),
title: Text(_your title here_),
)
...
);
}
所以,我唯一需要编辑的是favicon
So, the only thing I need to edit is the favicon
推荐答案
假设您已经有一个favicon.ico
文件,将其放置在your_project_dir\web
文件夹中与index.html
一起的位置,如下所示,足以供浏览器选择上.
Assuming you already have a favicon.ico
file, placing it inside the your_project_dir\web
folder alongside index.html
as shown below is enough for the browser to pick it up.
以下是放置favicon.ico' in the
web`文件夹的结果.确保执行干净的构建.
Following is the result of placing a favicon.ico' in the
web` folder. Make sure to do a clean build.
在其他情况下,您可以使用index.html
内的link
标记手动提及它,如本Wikipedia 页面.
In other case you can manually mention it using the link
tag inside your index.html
as explained here in this Wikipedia page.
这篇关于如何为扑朔迷离的Web应用程序设置标题和图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!