Flutter : Where is the title of Material App used?

亡梦爱人 提交于 2021-01-17 17:21:23

问题


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(),
      ),
    );
  }
}

回答1:


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




回答2:


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




回答3:


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.




回答4:


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.




回答5:


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'



来源:https://stackoverflow.com/questions/50615006/flutter-where-is-the-title-of-material-app-used

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!