fluttercommunity / fluttercommunity/flutter_downloader

_bindBackgroundIsolate run in main isolate

Open
#852 0 comments 0 reactions 1 assignee Claimed by @salmaahhmed View on GitHub
bug
Dominant language
Kotlin
Stars
940
Forks
561
Avg merge
1h 18m
Merged PRs (30d)
1

Description

First of all, this is not a bug, I just want to confirm the motivation of this prompt so that I will not be misled.
There is a method in Sample is downloadCallback(), which is defined as follows:
```
@pragma('vm:entry-point')
static void downloadCallback(
String id,
int status,
int progress,
) {
print(
'Callback on background isolate: '
'task ($id) is in status ($status) and process ($progress)',
);

IsolateNameServer.lookupPortByName('downloader_send_port')
?.send([id, status, progress]);
}
```
Why say Callback on background isolate: I added print information in this method:
```
@pragma('vm:entry-point')
static void downloadCallback(
String id,
int status,
int progress,
) {

print('Current isolate ID_dc: ${Isolate. current. hashCode}');
print('Current isolate name_dc: ${Isolate. current. debugName}');

print(
'Callback on background isolate: '
'task ($id) is in status ($status) and process ($progress)',
);

IsolateNameServer.lookupPortByName('downloader_send_port')
?.send([id, status, progress]);
}
```

The output is as follows:
flutter : Current isolate ID_dc: 1039319185
flutter : Current isolate name_dc: main

This means that the method is not running in the child isolate, can you tell me why?
In addition, there is a name in Sample called _bindBackgroundIsolate(), in fact, it does not ` Isolate.spawn` new sub-isolate.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.