我想在我现有的应用程序中实现是否安装了特定应用程序的条件。
条件:
the first app is that which is I'm going to build
Second app that is required for run first app
- 如果安装了应用程序(第二个应用程序),则
HomePage()
在第一个应用程序中运行 - 如果未安装应用程序,则显示安装应用程序的弹出窗口或警报。
第一个应用程序的根代码
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: Future.delayed(Duration(seconds: 2)),
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return MaterialApp(
home: Splash(),
debugShowCheckedModeBanner: false,
);
} else {
return StreamBuilder(
stream: Connectivity().onConnectivityChanged,
builder: (context, AsyncSnapshot<ConnectivityResult> snapshot) {
return snapshot.data == ConnectivityResult.mobile ||
snapshot.data == ConnectivityResult.wifi
? MaterialApp(
title: 'mFollower',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Homepage(),
debugShowCheckedModeBanner: false,
)
: NoInternet();
},
);
}
});
}
}