We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3621c69 commit 8a9b96dCopy full SHA for 8a9b96d
1 file changed
tools.py
@@ -222,7 +222,8 @@ def generate_code(work_bean):
222
out_res += (line + '\n')
223
if first and r'.fromParams({this.' in line:
224
class_name = line.split(r'.fromParams({this.')[0].strip()
225
- out_res += '\n factory %s(jsonStr) => %s.fromJson(json.decode(jsonStr));\n' % (class_name, class_name)
+ out_res += '\n factory %s(jsonStr) => jsonStr.runtimeType is String ? %s.fromJson(json.decode(jsonStr)) : %s.fromJson(jsonStr);\n' \
226
+ % (class_name, class_name, class_name)
227
first = False
228
return out_res
229
0 commit comments