Browse Source

增加对可空类型的处理。

Felix 2 years ago
parent
commit
fc3d813caa
1 changed files with 4 additions and 4 deletions
  1. 4 4
      ModeTypeGenerator.cs

+ 4 - 4
ModeTypeGenerator.cs

@@ -22,15 +22,15 @@ namespace FlutterCodeGenerator
                     duplicatedTime = _tempTypes[type];
                 }
                 duplicatedTime++;
-                if (type == typeof(int) || type == typeof(long) || type == typeof(short))
+                if (type == typeof(int) || type == typeof(long) || type == typeof(short) || type == typeof(int?) || type == typeof(long?) || type == typeof(short?))
                 {
                     return new IntModeType(argName);
                 }
-                else if (type == typeof(float) || type == typeof(double))
+                else if (type == typeof(float) || type == typeof(double) || type == typeof(float?) || type == typeof(double?))
                 {
                     return new DoubleModeType(argName);
                 }
-                else if (type == typeof(bool))
+                else if (type == typeof(bool) || (type == typeof(bool?)))
                 {
                     return new BoolModeType(argName);
                 }
@@ -42,7 +42,7 @@ namespace FlutterCodeGenerator
                 {
                     return new DateTimeModeType(argName);
                 }
-                else if (type == typeof(byte))
+                else if (type == typeof(byte) || type == typeof(byte?))
                 {
                     return new ByteModelType(argName);
                 }