【发布时间】:2020-11-29 20:10:29
【问题描述】:
我正在 Flutter 中创建一个 Android 启动器。每当用户打开应用程序时,我都需要显示启动器选择屏幕。我在这里找到了答案,但它适用于原生 Android 开发。如何将其与 Flutter 集成?
How to set default app launcher programmatically?
我已尝试创建新活动,但不确定在哪里调用该函数。
【问题讨论】:
我正在 Flutter 中创建一个 Android 启动器。每当用户打开应用程序时,我都需要显示启动器选择屏幕。我在这里找到了答案,但它适用于原生 Android 开发。如何将其与 Flutter 集成?
How to set default app launcher programmatically?
我已尝试创建新活动,但不确定在哪里调用该函数。
【问题讨论】:
在flutter的初始路由处设置一个页面。您可以在 MaterialApp 的 main.dart 文件中使用 initialRoute。然后在您的routes 中指定您的页面。阅读Defining the routes
MaterialApp(
// Start the app with the "/" named route. In this case, the app starts
// on the FirstScreen widget.
initialRoute: '/',
routes: {
// When navigating to the "/" route, build the FirstScreen widget.
'/': (context) => FakeLauncher()
},
);
【讨论】: