From 7dd8f4ca30037cb4dad37408bc42643827c95db3 Mon Sep 17 00:00:00 2001 From: Sumit Bhanushali Date: Mon, 20 Dec 2021 15:49:07 +0530 Subject: [PATCH] fixes #119, #121 --- lib/widgets/custom_form.dart | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/widgets/custom_form.dart b/lib/widgets/custom_form.dart index 998c272d..d98e4130 100644 --- a/lib/widgets/custom_form.dart +++ b/lib/widgets/custom_form.dart @@ -104,9 +104,25 @@ class CustomFormViewModel extends BaseViewModel { field.pVisible = 0; } } else { - field.pVisible = doc[field.dependsOn] is String - ? int.parse(doc[field.dependsOn]) - : doc[field.dependsOn]; + var dependsOnVal = doc[field.dependsOn]; + if (dependsOnVal is String) { + if (dependsOnVal.isEmpty) { + field.pVisible = 0; + } else { + if (dependsOnVal == "1") { + field.pVisible = 1; + } else if (dependsOnVal == "0") { + field.pVisible = 0; + } else { + field.pVisible = 1; + } + } + } else if (doc[field.dependsOn] is List) { + field.pVisible = doc[field.dependsOn].isEmpty ? 0 : 1; + } else { + // always visible if handling of type is missing + field.pVisible = 1; + } } }