|
@@ -295,12 +295,12 @@ namespace FlutterCodeGenerator
|
|
|
else if (listModelType.GenericArgumentModelType is SimpleModelType)
|
|
|
{
|
|
|
var model = listModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].cast<{model}>().toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].cast<{model}>().toList() : null,");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var model = listModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
|
|
|
}
|
|
|
}
|
|
|
else if (this is UserDefinedDerivedModelType definedDerivedModelType && definedDerivedModelType.BaseType is UserDefinedGenericModelType baseType)
|
|
@@ -312,12 +312,12 @@ namespace FlutterCodeGenerator
|
|
|
else if (listModelType.GenericArgumentModelType is SimpleModelType)
|
|
|
{
|
|
|
var model = listModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].cast<{model}>().toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].cast<{model}>().toList() : null,");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var model = listModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
|
|
|
}
|
|
|
}
|
|
|
else if (this is UserDefinedModeType || this is UserDefinedDerivedModelType)
|
|
@@ -325,12 +325,12 @@ namespace FlutterCodeGenerator
|
|
|
if (listModelType.GenericArgumentModelType is SimpleModelType)
|
|
|
{
|
|
|
var model = listModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].cast<{model}>().toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].cast<{model}>().toList() : null,");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var model = listModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -338,7 +338,7 @@ namespace FlutterCodeGenerator
|
|
|
{
|
|
|
var argumentName1 = dictionaryModelType.GenericArgumentModelTypeList[0].GetFlutterTypeName();
|
|
|
var argumentName2 = dictionaryModelType.GenericArgumentModelTypeList[1].GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].cast<{argumentName1},{argumentName2}>(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].cast<{argumentName1},{argumentName2}>() : null,");
|
|
|
}
|
|
|
else if (child is UserDefinedGenericModelType userDefinedGenericComplexModelType)
|
|
|
{
|
|
@@ -351,12 +351,12 @@ namespace FlutterCodeGenerator
|
|
|
else if (userDefinedGenericComplexModelType.GenericArgumentModelType is SimpleModelType)
|
|
|
{
|
|
|
var model = userDefinedGenericComplexModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].cast<{model}>().toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].cast<{model}>().toList() : null,");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var model = userDefinedGenericComplexModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
|
|
|
}
|
|
|
}
|
|
|
else if (this is UserDefinedModeType)
|
|
@@ -364,12 +364,12 @@ namespace FlutterCodeGenerator
|
|
|
if (userDefinedGenericComplexModelType.GenericArgumentModelType is SimpleModelType)
|
|
|
{
|
|
|
var model = userDefinedGenericComplexModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].cast<{model}>().toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].cast<{model}>().toList() : null,");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var model = userDefinedGenericComplexModelType.GenericArgumentModelType.GetFlutterTypeName();
|
|
|
- source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList(),");
|
|
|
+ source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? map['{child.Name_Upper}'].map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
|
|
|
}
|
|
|
}
|
|
|
}
|