-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
As per the title, while appCheck.getInstalledApps() is being executed, the entire UI is completely blocked.
Code snippet:
void initState() {
super.initState();
_loadApps();
}
Future<void> _loadApps() async {
AppCheck appCheck = AppCheck();
List<AppInfo>? apps = await appCheck.getInstalledApps();
setState(() {
_allApps = apps!;
});
}I also tried running getInstalledApps in a different Isolate, but it blocks the UI anyway:
static Future<void> _getAppsInIsolate(Map<String, dynamic> args) async {
SendPort sendPort = args['sendPort'];
RootIsolateToken rootIsolateToken = args['rootIsolateToken'];
BackgroundIsolateBinaryMessenger.ensureInitialized(rootIsolateToken);
List<AppInfo>? apps = await AppCheck().getInstalledApps();
sendPort.send(apps);
}
Future<void> _loadApps() async {
// Create a ReceivePort to get results from the isolate
ReceivePort receivePort = ReceivePort();
RootIsolateToken rootIsolateToken = RootIsolateToken.instance!;
// Spawn the isolate
Isolate isolate = await Isolate.spawn(_getAppsInIsolate, {
"rootIsolateToken": rootIsolateToken,
"sendPort": receivePort.sendPort,
});
// Listen for the result
final result = await receivePort.first;
_allApps = result as List<AppInfo>;
}Metadata
Metadata
Assignees
Labels
No labels