From c346cd9bb5cddd72637da327244e8368ff788d87 Mon Sep 17 00:00:00 2001 From: Andrea Antonello Date: Tue, 26 Nov 2024 08:17:30 +0100 Subject: [PATCH] fix empty string issue --- .../flutterlibs/forms/forms_widgets.dart | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/com/hydrologis/flutterlibs/forms/forms_widgets.dart b/lib/com/hydrologis/flutterlibs/forms/forms_widgets.dart index a707990..5cc3373 100644 --- a/lib/com/hydrologis/flutterlibs/forms/forms_widgets.dart +++ b/lib/com/hydrologis/flutterlibs/forms/forms_widgets.dart @@ -1064,9 +1064,27 @@ class ComboboxWidgetState extends State { } } + bool isInt = widget._formItem.type == TYPE_INTCOMBO; + T? value; if (widget._formItem.value != null) { - value = widget._formItem.value; + try { + if (isInt && widget._formItem.value is String) { + if (widget._formItem.value.isEmpty) { + value = null; + } else { + value = int.parse(widget._formItem.value) as T; + } + } else { + value = widget._formItem.value; + } + } on TypeError catch (er, st) { + print(er); + SMLogger() + .e("Error parsing value: ${widget._formItem.value}", null, st); + } on Exception catch (e, st) { + SMLogger().e("Error parsing value: ${widget._formItem.value}", e, st); + } } String? key = widget._formItem.key;