2021-09-19 12:59:45 +02:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
class DownloadEvent {
|
2021-10-02 11:12:54 +02:00
|
|
|
static StreamSubscription<DownloadCancelEvent> listenDownloadCancel() =>
|
|
|
|
_cancelStream.listen(null);
|
2021-09-19 12:59:45 +02:00
|
|
|
|
|
|
|
/// User canceled the download job
|
|
|
|
static const exceptionCodeUserCanceled = "userCanceled";
|
|
|
|
|
2021-10-02 11:12:54 +02:00
|
|
|
static const _downloadCancelChannel = EventChannel(
|
|
|
|
"com.nkming.nc_photos/download_event/action_download_cancel");
|
|
|
|
|
|
|
|
static late final _cancelStream = _downloadCancelChannel
|
|
|
|
.receiveBroadcastStream()
|
|
|
|
.map((data) => DownloadCancelEvent(
|
|
|
|
data["notificationId"],
|
|
|
|
));
|
2021-09-19 12:59:45 +02:00
|
|
|
}
|
|
|
|
|
2021-10-02 11:12:54 +02:00
|
|
|
class DownloadCancelEvent {
|
|
|
|
const DownloadCancelEvent(this.notificationId);
|
|
|
|
|
|
|
|
final int notificationId;
|
|
|
|
}
|