我正在为我的项目添加一个 workmanager flutter。现在它在Android系统上完美运行如下:
const fetchBackground = "fetchBackground";
void callbackDispatcher() {
Workmanager.executeTask((task, inputData) async {
switch (task) {
case fetchBackground:
Position userLocation = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
notif.Notification notification = new notif.Notification();
notification.showNotificationWithoutSound(userLocation);
break;
}
return Future.value(true);
});
}
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: …Run Code Online (Sandbox Code Playgroud) 我创建了一个 flutter 应用程序,现在我试图在我真正的 iPhone 上通过 XCode 运行它,但安装完成后,我面临以下问题:
另外,当我尝试在我的真机上运行该应用程序时,单击应用程序图标后,我面临出现白屏,然后应用程序直接关闭。
卡特琳娜 10.15.3
IOS 14.2
Xcode 11.7
我也信任手机中的应用程序
有谁知道这个问题的原因?
我尝试通过以下方式了解手机操作系统:flutter 应用程序中的 IOS 或 Android 是否正在其上运行:
@override
void initState() {
super.initState();
}
Run Code Online (Sandbox Code Playgroud)
以便在检测到操作系统后设置if条件。我怎样才能控制这个?有谁知道这个问题的解决方案?