Dart: Fix default values (#4795)

This commit is contained in:
Woody Guo 2018-06-29 01:12:18 +08:00 committed by Wouter van Oortmerssen
parent ea06768ad1
commit 3331805a1c
1 changed files with 12 additions and 2 deletions

View File

@ -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 += ")";
}