Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f312fd6

Browse files
committedMar 21, 2024··
accept null value for requests.
1 parent 2985260 commit f312fd6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎lib/basic_api/request.dart

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Request extends Equatable {
77
this.msgType,
88
this.passthrough,
99
this.reqId,
10+
this.acceptNullValue = false,
1011
});
1112

1213
/// Generate an instance from JSON.
@@ -25,6 +26,9 @@ class Request extends Equatable {
2526
/// [Optional] Used to map request to response.
2627
final int? reqId;
2728

29+
/// Determine accept null value in request or not.
30+
final bool acceptNullValue;
31+
2832
/// Converts an instance to JSON.
2933
Map<String, dynamic> toJson() => <String, dynamic>{
3034
'passthrough': passthrough,

‎lib/services/connection/call_manager/base_call_manager.dart

+7-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@ abstract class BaseCallManager<T> {
105105
required Request request,
106106
required bool isSubscription,
107107
}) {
108-
final Map<String, dynamic> result = request.toJson()
109-
..removeWhere((String key, dynamic value) => value == null);
108+
final Map<String, dynamic> result;
109+
if (request.acceptNullValue) {
110+
result = request.toJson();
111+
} else {
112+
result = request.toJson()
113+
..removeWhere((String key, dynamic value) => value == null);
114+
}
110115

111116
if (isSubscription) {
112117
result.putIfAbsent('subscribe', () => 1);

0 commit comments

Comments
 (0)
Please sign in to comment.