From 3331805a1c44162f7bbc2f843b0781d8fdbe9e83 Mon Sep 17 00:00:00 2001 From: Woody Guo Date: Fri, 29 Jun 2018 01:12:18 +0800 Subject: [PATCH] Dart: Fix default values (#4795) --- src/idl_gen_dart.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/idl_gen_dart.cpp b/src/idl_gen_dart.cpp index 3f2555d5d..6fb5f9ea7 100644 --- a/src/idl_gen_dart.cpp +++ b/src/idl_gen_dart.cpp @@ -518,9 +518,19 @@ class DartGenerator : public BaseGenerator { code += ".vTableGet(_bc, _bcOffset, " + NumToString(field.value.offset) + ", "; if (!field.value.constant.empty() && field.value.constant != "0") { - code += field.value.constant; + if (IsBool(field.value.type.base_type)) { + code += "true"; + } else { + code += field.value.constant; + } } else { - code += "null"; + if (IsBool(field.value.type.base_type)) { + code += "false"; + } else if (IsScalar(field.value.type.base_type)) { + code += "0"; + } else { + code += "null"; + } } code += ")"; }