RYO*_*YOK 4 production build flutter
我有我的应用程序,我已经更改了它的名称并且显示正确,但是当您在手机上看到打开的应用程序时,该应用程序没有名称,但是当您在应用程序列表中看到它的图标时,它显示正确,您将从图片中得到想法
\n在 5 种不同的设备上进行了测试
\n应用程序列表中的应用程序图标(正确显示)
\n\n查看打开的应用程序时的应用程序名称
\n\n我不知道为什么会发生这种情况,我将与您分享我的清单,请告诉我如何解决此问题
\n这是 AndroidManifest.xml
\n package="com.eco.cat">\n <!-- io.flutter.app.FlutterApplication is an android.app.Application that\n calls FlutterMain.startInitialization(this); in its onCreate method.\n In most cases you can leave this as-is, but you if you want to provide\n additional functionality it is fine to subclass or reimplement\n FlutterApplication and put your custom class here. -->\n <application\n android:name="io.flutter.app.FlutterApplication"\n android:label="EcoCat"\n android:icon="@mipmap/ic_launcher">\n <activity\n android:name=".MainActivity"\n android:launchMode="singleTop"\n android:theme="@style/LaunchTheme"\n android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"\n android:hardwareAccelerated="true"\n android:windowSoftInputMode="adjustResize">\n <intent-filter>\n <action android:name="android.intent.action.MAIN"/>\n <category android:name="android.intent.category.LAUNCHER"/>\n </intent-filter>\n </activity>\n <!-- Don\'t delete the meta-data below.\n This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->\n <meta-data\n android:name="flutterEmbedding"\n android:value="2" />\n </application>\n <uses-permission android:name="android.permission.INTERNET"/>\n</manifest>\nRun Code Online (Sandbox Code Playgroud)\n我的 main.dart
\nimport \'Front-end/home/Companies.dart\';\nimport \'Front-end/search/Search.dart\';\nimport \'Front-end/settings/Settings.dart\';\nimport \'file:///D:/programming/Android_Development/Projects/coupon_app/lib/reusable_widgets/functions/Device_Information.dart\';\nimport \'package:app/reusable_widgets/logic/Check_SiteStatus.dart\';\nimport \'package:app/reusable_widgets/logic/Responsiveness-Controller.dart\';\nimport \'package:curved_navigation_bar/curved_navigation_bar.dart\';\nimport \'package:flutter/material.dart\';\nimport \'package:flutter_phoenix/flutter_phoenix.dart\';\nimport \'package:provider/provider.dart\';\nimport \'Themes/DarkThemeProvider.dart\';\nimport \'Themes/DarkThemeStyle.dart\';\nimport \'package:flutter/services.dart\';\n\n void main() {\n WidgetsFlutterBinding.ensureInitialized();\n SystemChrome.setPreferredOrientations(\n [DeviceOrientation.portraitUp , DeviceOrientation.portraitDown])\n .then((_) => runApp(\n Phoenix(\n child: MyApp(),\n ),\n ),\n );\n}\n\nclass MyApp extends StatefulWidget {\n // This widget is the root of your application.\n @override\n _MyAppState createState() => _MyAppState();\n}\n\n\nclass _MyAppState extends State<MyApp> {\n DarkThemeProvider themeChangeProvider = new DarkThemeProvider();\n @override\n\n void initState() {\n super.initState();\n getCurrentAppTheme();\n }\n\n void getCurrentAppTheme() async {\n themeChangeProvider.darkTheme =\n await themeChangeProvider.darkThemePreference.getTheme();\n }\n\n Widget build(BuildContext context) {\n return\n ChangeNotifierProvider(\n create: (_) {\n return themeChangeProvider;\n },\n child: Consumer<DarkThemeProvider>(\n builder: (BuildContext context, value, Widget child) {\n return MaterialApp(\n debugShowCheckedModeBanner: false,\n theme: Styles.themeData(themeChangeProvider.darkTheme, context),\n home: MyHomePage(),\n );\n },\n ),\n );\n }\n}\n\n\n\nclass MyHomePage extends StatefulWidget {\n @override\n _MyHomePageState createState() => _MyHomePageState();\n}\n\nclass _MyHomePageState extends State<MyHomePage> {\n //bottom navbar items to build body\n int _currentIndex = 1;\n final List<Widget> _children = [\n Search(),\n CompaniesPage(),\n Settings(),\n ];\n @override\n Widget build(BuildContext context) {\n //checks web server status\n checkSiteStatus(context);\n Color themeColor = Theme.of(context).backgroundColor;\n void changePage(int index){\n setState(() {\n _currentIndex = index;\n });\n }\n //setting app name based on current page\n String title = \'\';\n if(_currentIndex == 0){\n title = \'\xd8\xa7\xd8\xa8\xd8\xad\xd8\xab \xd8\xa8\xd8\xa7\xd8\xb3\xd8\xaa\xd8\xae\xd8\xaf\xd8\xa7\xd9\x85 \xd8\xa7\xd9\x84\xd8\xaa\xd8\xb5\xd9\x86\xd9\x8a\xd9\x81\xd8\xa7\xd8\xaa\';\n }else if(_currentIndex == 1){\n title = \'\xd8\xa7\xd9\x84\xd8\xb4\xd8\xb1\xd9\x83\xd8\xa7\xd8\xaa\';\n }else if(_currentIndex == 2){\n title = \'\xd8\xa7\xd9\x84\xd8\xa7\xd8\xb9\xd8\xaf\xd8\xa7\xd8\xaf\xd8\xa7\xd8\xaa\';\n }\n return Scaffold(\n appBar: AppBar(\n // Here we take the value from the MyHomePage object that was created by\n // the App.build method, and use it to set our appbar title.\n bottomOpacity: 0.0,\n elevation: 0.0,\n title: new Center(\n child: Text(\'$title\',\n style: TextStyle(color: Colors.white ,\n fontSize: DeviceInformation(context).width * ResponsivenessController(context).responsiveFont\n ),\n ),\n ),\n ),\n body: _children[_currentIndex],\n bottomNavigationBar: CurvedNavigationBar(\n index: _currentIndex,\n color: themeColor,\n backgroundColor: Colors.cyan,\n height: 75.0,\n items:<Widget>[\n Icon(Icons.search, size: DeviceInformation(context).height * ResponsivenessController(context).responsiveNavIcons),\n Icon(Icons.home, size: DeviceInformation(context).height * ResponsivenessController(context).responsiveNavIcons),\n Icon(Icons.settings, size: DeviceInformation(context).height * ResponsivenessController(context).responsiveNavIcons),\n ],\n onTap: changePage,\n ),\n );\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n
小智 21
MaterialApp是使用 Material Design 的 Flutter 应用程序的入口点,因此它只能在MyApp小部件中声明一次。它的文档在这里。
正如文档中所解释的, MaterialApp 的title属性是看到打开的应用程序时的属性。AndroidManifest 中的android:label是显示在主屏幕上的标题。
您应该使用以下代码设置标题
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: Styles.themeData(themeChangeProvider.darkTheme, context),
home: MyHomePage(),
title: "EcoCat",
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2551 次 |
| 最近记录: |