From d59e16da4cdaebb3a9c63ccf39590b70e24183a9 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Sun, 30 Jul 2023 23:36:54 +0200 Subject: [PATCH] override `operator ==` and `hashCode` for `DownloadTask` (#875) * override `operator ==` and `hashCode` for `DownloadTask` * bump version to 1.10.7 * remove caching from github actions --- .github/workflows/prepare.yaml | 1 - .github/workflows/publish.yaml | 1 - CHANGELOG.md | 4 ++++ lib/src/models.dart | 31 +++++++++++++++++++++++++++++++ pubspec.yaml | 2 +- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prepare.yaml b/.github/workflows/prepare.yaml index 77cf8d82..3c02310d 100644 --- a/.github/workflows/prepare.yaml +++ b/.github/workflows/prepare.yaml @@ -23,7 +23,6 @@ jobs: uses: subosito/flutter-action@v2 with: flutter-version: ${{ matrix.flutter-version }} - cache: true - name: flutter pub get run: flutter pub get diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index c8186ac6..3a390bd0 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -27,7 +27,6 @@ jobs: uses: subosito/flutter-action@v2 with: channel: stable - cache: true - name: Publish to pub.dev id: pub_release diff --git a/CHANGELOG.md b/CHANGELOG.md index a5dddf23..cf07fdc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.10.7 + +- Override `operator ==` and `hashCode` for `DownloadTask` (#875) + ## 1.10.6 - Fix `delete()` not working when file isn't saved to public storage (#871) diff --git a/lib/src/models.dart b/lib/src/models.dart index 5801e31b..45a76874 100644 --- a/lib/src/models.dart +++ b/lib/src/models.dart @@ -89,4 +89,35 @@ class DownloadTask { @override String toString() => 'DownloadTask(taskId: $taskId, status: $status, progress: $progress, url: $url, filename: $filename, savedDir: $savedDir, timeCreated: $timeCreated, allowCellular: $allowCellular)'; + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + + return other is DownloadTask && + other.taskId == taskId && + other.status == status && + other.progress == progress && + other.url == url && + other.filename == filename && + other.savedDir == savedDir && + other.timeCreated == timeCreated && + other.allowCellular == allowCellular; + } + + @override + int get hashCode { + return Object.hash( + taskId, + status, + progress, + url, + filename, + savedDir, + timeCreated, + allowCellular, + ); + } } diff --git a/pubspec.yaml b/pubspec.yaml index 0226485d..86d08264 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_downloader description: Powerful plugin making it easy to download files. -version: 1.10.6 +version: 1.10.7 repository: https://github.com/fluttercommunity/flutter_downloader issue_tracker: https://github.com/fluttercommunity/flutter_downloader/issues maintainer: Bartek Pacia (@bartekpacia)