Flutter : Where is the title of Material App used?

DartFlutter

Dart Problem Overview


The flutter app name is shown by the package name, the AppBar title is shown on the AppBar of the home page, so where does the title MaterialApp(title: 'Rectangle App',); is used in flutter projects.

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Rectangle App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Rectangle App Home Page'),
        ),
        body: HelloRectangle(),
      ),
    );
  }
}

Dart Solutions


Solution 1 - Dart

This is a good question. Below is the the explanation of how it is used:

> A one-line description used by the device to identify the app for the user. > > On Android the titles appear above the task manager's app snapshots > which are displayed when the user presses the "recent apps" button. > Similarly, on iOS the titles appear in the App Switcher when the user > double presses the home button.

So in short:

  • On Android: it is used in Recent apps

  • On iOS: it is used in App switcher

Update 11th Feb, 2020:

The document is updated (I don't know exactly the updated time)

> A one-line description used by the device to identify the app for the > user. On Android the titles appear above the task manager's app > snapshots which are displayed when the user presses the "recent apps" > button. On iOS this value cannot be used. CFBundleDisplayName from the > app's Info.plist is referred to instead whenever present, CFBundleName > otherwise. To provide a localized title instead, use > [onGenerateTitle].

So this value has no effect on iOS

Solution 2 - Dart

In "Flutter for Web", it's used in browser-tabs, which corresponds to the web app's 'title' property.

Solution 3 - Dart

UPDATE: To be complete, now that Flutter is being implemented on more platforms, like the mentioned web platform and the upcoming desktop support my current answer is probably no longer adequate.

The title property of the MaterialApp class is still used as originally described:
A one-line description used by the device to identify the app for the user.

On Android the 'title' property appears above the task manager's app snapshots which are displayed when the user presses the "recent apps" button or trigger the same functionality using a gesture.

On iOS this value has no effect.

'CFBundleDisplayName' from the app's 'Info.plist' is referred to instead whenever present and 'CFBundleName' otherwise. This is still the case.

You can open the iOS module in Xcode to change the value in Info.plist to change what is displayed on iOS.

This is also true when using the CupertinoApp class on iOS.

In other contexts, the title property is meant to be used by the "OS task switcher". so what that means in practice as Flutter gets implemented on more platforms remains to see.

But as mentioned, the value is passed to a browser-tab's title when used with Flutter for the web, and to the window title when used on the (as of this date) experimental macOS and Linux desktop platforms and as the app title when using the OS app switchers like ⌘ + Tab on macOS.

Solution 4 - Dart

As per the official doc:

> A one-line description used by the device to identify the app for the > user. > > On Android the titles appear above the task manager's app snapshots > which are displayed when the user presses the "recent apps" button. On > iOS this value cannot be used. CFBundleDisplayName from the app's > Info.plist is referred to instead whenever present, CFBundleName > otherwise.

1. Useful for the Android only.

2. On iOS this value cannot be used.

Solution 5 - Dart

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: Elements.getThemeData(),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

when you put the app background title is demonstrated. A page title is shown as 'Flutter Demo Home Page'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTushar RaiView Question on Stackoverflow
Solution 1 - DartPhuc TranView Answer on Stackoverflow
Solution 2 - DartjuanarzacView Answer on Stackoverflow
Solution 3 - DartC. SederqvistView Answer on Stackoverflow
Solution 4 - DartSANATView Answer on Stackoverflow
Solution 5 - DartSamet ÖZTOPRAKView Answer on Stackoverflow