Skip to content

Commit a0079ec

Browse files
committed
+fix Fix small issue with rootData in Model class
1 parent e826f54 commit a0079ec

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/src/models/model.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class Model extends BaseModel {
1919
//
2020
//
2121

22-
final Map<String, dynamic> _rootData;
23-
Map<String, dynamic> get rootData => Map.unmodifiable(_rootData);
22+
final Map<String, dynamic>? _rootData;
23+
Map<String, dynamic> get rootData => _rootData != null ? Map.unmodifiable(_rootData) : toJson();
2424

2525
//
2626
//
@@ -88,7 +88,7 @@ class Model extends BaseModel {
8888
Map<String, dynamic> toJson({
8989
bool includeNulls = false,
9090
}) {
91-
return includeNulls ? _rootData : _rootData.nonNulls;
91+
return (includeNulls ? _rootData : _rootData?.nonNulls) ?? {};
9292
}
9393

9494
//

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
name: df_generate_dart_models_core
1414
description: A package that provides core dependencies for models generated with df_generate_dart_models.
15-
version: 0.8.2
15+
version: 0.8.3
1616
repository: https://github.com/DevCetra/df_generate_dart_models_core
1717
funding:
1818
- https://www.buymeacoffee.com/robmllze

0 commit comments

Comments
 (0)