diff --git a/dio/CHANGELOG.md b/dio/CHANGELOG.md index 4a43995d..4243c162 100644 --- a/dio/CHANGELOG.md +++ b/dio/CHANGELOG.md @@ -7,6 +7,7 @@ See the [Migration Guide][] for the complete breaking changes list.** - Update comments and strings with `MultipartFile`. - Removes redundant warnings when composing request options on Web. +- Fixes boundary inconsistency in `FormData.clone()`. ## 5.7.0 diff --git a/dio/lib/src/form_data.dart b/dio/lib/src/form_data.dart index 10bc5f62..2fc4cd54 100644 --- a/dio/lib/src/form_data.dart +++ b/dio/lib/src/form_data.dart @@ -74,7 +74,7 @@ class FormData { /// /// See also: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html String get boundary => _boundary; - late final String _boundary; + late String _boundary; /// The form fields to send for this request. final fields = >[]; @@ -210,6 +210,7 @@ class FormData { // Convenience method to clone finalized FormData when retrying requests. FormData clone() { final clone = FormData(); + clone._boundary = _boundary; clone.fields.addAll(fields); for (final file in files) { clone.files.add(MapEntry(file.key, file.value.clone())); diff --git a/dio/test/formdata_test.dart b/dio/test/formdata_test.dart index 109a5324..ee299ecd 100644 --- a/dio/test/formdata_test.dart +++ b/dio/test/formdata_test.dart @@ -176,6 +176,7 @@ void main() async { expect(fm1 != fm, true); expect(fm1.files[0].value.filename, fm.files[0].value.filename); expect(fm1.fields, fm.fields); + expect(fm1.boundary, fm.boundary); }, testOn: 'vm', );