Skip to content

Commit 7146061

Browse files
authored
Merge pull request #165 from ilmalte/fix/154-listMatches-deserialization
Fix match serialization by adding default values and runtime type handling
2 parents 1f71506 + c28997f commit 7146061

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

nakama/lib/src/nakama_client/nakama_api_client.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,15 @@ class NakamaRestApiClient extends NakamaBaseClient {
14151415
query: query,
14161416
);
14171417

1418-
return res.matches?.map((e) => model.Match.fromJson(e.toJson())).toList(growable: false) ?? [];
1418+
return res.matches?.map((e) {
1419+
final json = e.toJson();
1420+
json['runtimeType'] = 'default';
1421+
// Handle null values that are required fields in the domain model
1422+
json['authoritative'] ??= false;
1423+
json['label'] ??= '';
1424+
json['presences'] ??= <Map<String, dynamic>>[];
1425+
return model.Match.fromJson(json);
1426+
}).toList(growable: false) ?? [];
14191427
} on Exception catch (e) {
14201428
throw _handleError(e);
14211429
}

0 commit comments

Comments
 (0)