Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser tab shows project name while Flutter Web app loading

I'm creating a Flutter Web app. When it is starting up and downloading the Flutter content the tab in the browser displays the project name instead of the app name. This looks ugly.

enter image description here

My project name is com.example.my_app_client, but my app name is My App.

How do I change the browser tab text to show "My App"?

I found the answer and I am adding it below as a Q&A style self answer.

like image 476
Suragch Avatar asked Apr 20 '20 04:04

Suragch


3 Answers

There is a top level folder called web inside your project. Open the index.html file in that folder and you should see something similar to the following:

web/index.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>my_app_client</title>
</head>
<body>
  <script src="main.dart.js" type="application/javascript"></script>
</body>
</html>

Change the title text to your app name:

<title>My App</title>

This will then show the correct title while the Flutter app is loading.

enter image description here

like image 129
Suragch Avatar answered Oct 06 '22 19:10

Suragch


You can also use the title property on the MaterialApp widget, this is what worked for me

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title:'Your Title',
      home: HomePage(),
      theme: appTheme(),
    );
  }
}

like image 21
6thsage Avatar answered Oct 06 '22 18:10

6thsage


You can edit the web/manifest.json file.

{
    "name": "<App name>",
    "short_name": "<App short name>",
    "description": "<Your app description>",
    // something else
}

after this build the app again and open it in incognito tab or clear browsing data

like image 1
Dhirajraje Avatar answered Oct 06 '22 18:10

Dhirajraje