-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Resolve ListParam equality issue for caching identical requests (#…
…2366) ### What this PR does Resolves #2364 This PR addresses an issue with ListParam equality, where identical requests were not recognized as the same due to reference comparison of lists. This caused multiple identical requests to be sent to the server, even when caching was implemented. ### Changes introduced Updated ListParam's operator == to use DeepCollectionEquality for proper deep equality comparison of list contents. Added relevant unit tests to validate the fix and ensure no regression.
- Loading branch information
Showing
4 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('ListParam', () { | ||
test('param1 and param2 should be considered equal', () { | ||
final param1 = const ListParam(['item1', 'item2'], ListFormat.csv); | ||
final param2 = const ListParam(['item1', 'item2'], ListFormat.csv); | ||
expect(param1 == param2, isTrue); | ||
}); | ||
|
||
test('param1 and param3 should not be considered equal', () { | ||
final param1 = const ListParam(['item1', 'item2'], ListFormat.csv); | ||
final param3 = const ListParam(['item3', 'item4'], ListFormat.csv); | ||
expect(param1 == param3, isFalse); | ||
}); | ||
|
||
test('Order matters: param1 and param4 should not be equal', () { | ||
final param1 = const ListParam(['item1', 'item2'], ListFormat.csv); | ||
final param4 = const ListParam(['item2', 'item1'], ListFormat.csv); | ||
expect(param1 == param4, isFalse); | ||
}); | ||
}); | ||
} |