Skip to content

Commit 5e9e34b

Browse files
committed
fix: InboundService fixes to match backend logic
1 parent 0f2193e commit 5e9e34b

13 files changed

Lines changed: 199 additions & 80 deletions

.fvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"flutter": "3.41.8",
2+
"flutter": "3.41.9",
33
"flavors": {}
44
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 3.8.12
4+
5+
- Made `position` field nullable (`InboundPositionStructure?`) in `InboundStructure` and `InboundStructureInput` to support services without a position structure.
6+
- Added `DynamicMapConverter` and `DynamicMapConverterNullable` converters to safely deserialize `Map<dynamic, dynamic>` (e.g. Dart literal `{}`) into `Map<String, dynamic>`.
7+
- Applied `@DynamicMapConverterNullable()` to `InboundService.credentials` and `@DynamicMapConverter()` to `InboundServiceInput.credentials` to fix deserialization failures when credentials arrive as an empty map literal.
8+
39
## 3.8.11
410

511
- Adjustments on `Model`, now `widget` is `List<RenderWidget>` instead of plain `RenderWidget`.

devtools_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
description: This file stores settings for Dart & Flutter DevTools.
22
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
33
extensions:
4+
- drift: false
5+
- shared_preferences: false

lib/src/builder/builder.freezed.dart

Lines changed: 55 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/builder/builder.g.dart

Lines changed: 12 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/builder/src/inbound.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ part of '../builder.dart';
44
abstract class InboundStructure with _$InboundStructure {
55
const factory InboundStructure({
66
required bool hasPosition,
7-
required InboundPositionStructure position,
7+
required InboundPositionStructure? position,
88
required bool hasPayload,
99
required List<InboundPayloadStructure> payload,
1010
}) = _InboundStructure;
@@ -19,7 +19,7 @@ abstract class InboundStructureInput with _$InboundStructureInput {
1919
@Default(true) bool hasPosition,
2020

2121
/// [position] defines the structure of the position.
22-
required InboundPositionStructureInput position,
22+
required InboundPositionStructureInput? position,
2323

2424
/// [hasPayload] defines if the structure has a payload.
2525
@Default(false) bool hasPayload,
@@ -90,7 +90,8 @@ enum InboundPayloadStructureType {
9090
string,
9191
integer,
9292
boolean,
93-
float;
93+
float
94+
;
9495

9596
@override
9697
String toString() => toJson();

lib/src/converters/converters.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ part 'src/time_of_day.dart';
1515
part 'src/regex.dart';
1616
part 'src/byte_list.dart';
1717
part 'src/param_converter.dart';
18+
part 'src/dynamic_map.dart';
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
part of '../converters.dart';
2+
3+
/// Safely converts any [Map] into [Map<String, dynamic>?].
4+
///
5+
/// A Dart literal `{}` inside a `Map<String, dynamic>` value slot is
6+
/// `Map<dynamic, dynamic>`, which fails the direct `as Map<String, dynamic>?`
7+
/// cast that json_serializable emits. This converter handles both variants.
8+
class DynamicMapConverterNullable implements JsonConverter<Map<String, dynamic>?, Object?> {
9+
const DynamicMapConverterNullable();
10+
11+
@override
12+
Map<String, dynamic>? fromJson(Object? json) {
13+
if (json == null) return null;
14+
if (json is Map<String, dynamic>) return json;
15+
if (json is Map) return json.map((key, value) => MapEntry(key.toString(), value));
16+
return null;
17+
}
18+
19+
@override
20+
Object? toJson(Map<String, dynamic>? value) => value;
21+
}
22+
23+
class DynamicMapConverter implements JsonConverter<Map<String, dynamic>, Object?> {
24+
const DynamicMapConverter();
25+
26+
@override
27+
Map<String, dynamic> fromJson(Object? json) {
28+
if (json is Map<String, dynamic>) return json;
29+
if (json is Map) return json.map((key, value) => MapEntry(key.toString(), value));
30+
return {};
31+
}
32+
33+
@override
34+
Object? toJson(Map<String, dynamic> value) => value;
35+
}

lib/src/inbound/inbound.freezed.dart

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)