This repository has been archived by the owner on Sep 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: updating receive logic for running from isolate
Have to update ui from callback instead passing animationcontroller for supporting isolates
- Loading branch information
Showing
5 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'dart:developer'; | ||
import 'dart:ui'; | ||
import 'package:workmanager/workmanager.dart'; | ||
|
||
enum MyTasks { receive } | ||
|
||
enum IsolatePorts { receive } | ||
|
||
final _workManager = Workmanager(); | ||
|
||
@pragma("vm:entry-point") | ||
void _callBack() { | ||
_workManager.executeTask((taskName, inputData) async { | ||
final task = | ||
MyTasks.values.singleWhere((element) => element.name == taskName); | ||
switch (task) { | ||
case MyTasks.receive: | ||
final sendPort = | ||
IsolateNameServer.lookupPortByName(IsolatePorts.receive.name); | ||
return true; | ||
} | ||
}); | ||
} | ||
|
||
Future<void> initalize() async { | ||
throw UnimplementedError(); | ||
// ignore: dead_code | ||
await _workManager.initialize(_callBack); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79eef8e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#7