Browse Source

修复Expected a value of type 'List<TypeDataItemDTO>?', but got one of type 'List<dynamic>'

Felix 3 years ago
parent
commit
3a510c2a54
1 changed files with 5 additions and 5 deletions
  1. 5 5
      ModeType.cs

+ 5 - 5
ModeType.cs

@@ -306,7 +306,7 @@ namespace FlutterCodeGenerator
                         else
                         {
                             var model = listModelType.GenericArgumentModelType.GetFlutterTypeName();
-                            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,");
+                            source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? (map['{child.Name_Upper}'] as List).map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
                         }
                     }
                     else if (this is UserDefinedDerivedModelType definedDerivedModelType && definedDerivedModelType.BaseType is UserDefinedGenericModelType baseType)
@@ -323,7 +323,7 @@ namespace FlutterCodeGenerator
                         else
                         {
                             var model = listModelType.GenericArgumentModelType.GetFlutterTypeName();
-                            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,");
+                            source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? (map['{child.Name_Upper}'] as List).map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
                         }
                     }
                     else if (this is UserDefinedModeType || this is UserDefinedDerivedModelType)
@@ -336,7 +336,7 @@ namespace FlutterCodeGenerator
                         else
                         {
                             var model = listModelType.GenericArgumentModelType.GetFlutterTypeName();
-                            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,");
+                            source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? (map['{child.Name_Upper}'] as List).map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
                         }
                     }
                 }
@@ -362,7 +362,7 @@ namespace FlutterCodeGenerator
                         else
                         {
                             var model = userDefinedGenericComplexModelType.GenericArgumentModelType.GetFlutterTypeName();
-                            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,");
+                            source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? (map['{child.Name_Upper}'] as List).map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
                         }
                     }
                     else if (this is UserDefinedModeType)
@@ -375,7 +375,7 @@ namespace FlutterCodeGenerator
                         else
                         {
                             var model = userDefinedGenericComplexModelType.GenericArgumentModelType.GetFlutterTypeName();
-                            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,");
+                            source.AppendLine($"\t\t\t{child.Name_Lower}: map['{child.Name_Upper}'] != null ? (map['{child.Name_Upper}'] as List).map((e)=>{model}.fromJson(e as Map<String,dynamic>)).toList() : null,");
                         }
                     }
                 }