Skip to content

Commit

Permalink
Update v0.2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
incrediblezayed committed Mar 11, 2024
1 parent 13fb3b1 commit 78d6f99
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 44 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [0.2.12]
* Minor network related bug fixes, fixing issue [#105](https://github.com/incrediblezayed/file_saver/issues/105)
* & Issue [#106](https://github.com/incrediblezayed/file_saver/issues/106)

## [0.2.11]
* Merged PR [#87](https://github.com/incrediblezayed/file_saver/pull/87) for backward compatibility with the older versions of java

Expand Down
4 changes: 4 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}
}


Expand Down
42 changes: 33 additions & 9 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.10"
version: "0.2.11"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -175,6 +175,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.1"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
Expand All @@ -195,10 +219,10 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -392,10 +416,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.6.1"
typed_data:
dependency: transitive
description:
Expand All @@ -412,14 +436,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
vm_service:
dependency: transitive
description:
name: web
sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05"
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "0.4.2"
version: "13.0.0"
win32:
dependency: transitive
description:
Expand Down
43 changes: 22 additions & 21 deletions lib/src/models/link_details.dart
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';

class LinkDetails {
final String link;
final String method;
final Object? body;
final Map<String, String>? headers;
final Map<String, dynamic>? queryParameters;
final ResponseType responseType;
LinkDetails({
required this.link,
this.headers,
this.body,
this.method = 'GET',
this.queryParameters,
this.responseType = ResponseType.bytes,
});

LinkDetails copyWith({
String? link,
String? method,
Object? body,
Map<String, String>? headers,
}) {
return LinkDetails(
link: link ?? this.link,
body: body ?? this.body,
method: method ?? this.method,
headers: headers ?? this.headers,
);
}

@override
String toString() => 'LinkDetails(link: $link, headers: $headers)';

@override
bool operator ==(covariant LinkDetails other) {
if (identical(this, other)) return true;

return other.link == link &&
mapEquals(other.headers, headers) &&
other.method == method &&
other.body == body;
other.body == body &&
mapEquals(other.headers, headers) &&
mapEquals(other.queryParameters, queryParameters) &&
other.responseType == responseType;
}

@override
int get hashCode =>
link.hashCode ^ headers.hashCode ^ method.hashCode ^ body.hashCode;
int get hashCode {
return link.hashCode ^
method.hashCode ^
body.hashCode ^
headers.hashCode ^
queryParameters.hashCode ^
responseType.hashCode;
}

@override
String toString() {
return 'LinkDetails(link: $link, method: $method, body: $body, headers: $headers, queryParameters: $queryParameters, responseType: $responseType)';
}
}
17 changes: 15 additions & 2 deletions lib/src/utils/helpers.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:developer';
import 'dart:io';

Expand Down Expand Up @@ -44,12 +45,24 @@ class Helpers {
);
Response response = await dio.request(
link.link,
data: link.body,
queryParameters: link.queryParameters,
);
if (transformDioResponse != null) {
return transformDioResponse(response.data);
} else {
if (response.data is Uint8List) {
return response.data;
} else if (response.data is List<int>) {
return Uint8List.fromList(response.data);
} else if (response.data is String) {
return utf8.encode(response.data);
} else {
throw Exception(
'Invalid data type, if you have a different response type, then provide the transformDioResponse function',
);
}
}
Uint8List bytes = response.data;
return bytes;
}

///This method provides default downloads directory for saving the file for Android, iOS, Linux, Windows, macOS
Expand Down
44 changes: 34 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ packages:
dependency: "direct main"
description:
name: dio
sha256: "797e1e341c3dd2f69f2dad42564a6feff3bfb87187d05abb93b9609e6f1645c3"
sha256: "49af28382aefc53562459104f64d16b9dfd1e8ef68c862d5af436cc8356ce5a8"
url: "https://pub.dev"
source: hosted
version: "5.4.0"
version: "5.4.1"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -96,6 +96,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
Expand All @@ -116,10 +140,10 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -249,10 +273,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.6.1"
typed_data:
dependency: transitive
description:
Expand All @@ -269,14 +293,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
vm_service:
dependency: transitive
description:
name: web
sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05"
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "0.4.2"
version: "13.0.0"
win32:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: file_saver
description: >-
This package will help you save file with a single method on any platform
including macOS, iOS, Android, Windows, Web, Linux.
version: 0.2.11
version: 0.2.12
repository: https://github.com/incrediblezayed/file_saver
homepage: https://hassanansari.dev

Expand All @@ -18,7 +18,7 @@ dependencies:
path_provider: ^2.1.2
path_provider_windows: ^2.2.1
path_provider_linux: ^2.2.1
dio: ^5.4.0
dio: ^5.4.1

dev_dependencies:
flutter_lints: ^3.0.1
Expand Down

0 comments on commit 78d6f99

Please sign in to comment.