Flutter
前言
MaterialApp 有一個Title屬性,一開始以為是ActionBar的title,后來發現不是,查看原始碼的時候,注釋解釋說在Android端是多任務狀態下的title,
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'MaterialApp Title',
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
如下圖:

原始碼
-
Android
在Android上,標題出現在任務管理器的應用程式快照上方,當用戶按下“最近的應用程式”按鈕時會顯示, -
iOS
在iOS上,此值設定無效,應用程式使用的還是 Info.plist 中的 CbundleDisplayName,或者 CFBundleName, -
Web
在web上,它用作頁面標題,顯示在瀏覽器的打開選項卡串列中,
# material/app.dart
/// {@macro flutter.widgets.widgetsApp.title}
///
/// This value is passed unmodified to [WidgetsApp.title].
final String title;
===================================================================
# widgets/app.dart
/// {@template flutter.widgets.widgetsApp.title}
/// 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.
/// On the web it is used as the page title, which shows up in the browser's list of open tabs.
///
/// To provide a localized title instead, use [onGenerateTitle].
/// {@endtemplate}
final String title;
#參考
https://api.flutter.dev/flutter/material/MaterialApp/title.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/374819.html
標籤:其他
