diff --git a/lib/src/form/src/controller.dart b/lib/src/form/src/controller.dart index 0fcab5b..cc9a205 100644 --- a/lib/src/form/src/controller.dart +++ b/lib/src/form/src/controller.dart @@ -97,7 +97,12 @@ class AstromicFormController extends FormController { /// Get the value of a hosted state variable using it's ID. T? getValue(String id) { prepareValue(id, false); - return _hostedValues[id]?.$1?.$1; + + if (_hostedValues[id]?.$1 is T?) { + return _hostedValues[id]?.$1; + } else { + throw FlutterError('Value found but is not of the type $T, it\'s of type ${_hostedValues[id]?.$1.runtimeType}'); + } } @override diff --git a/lib/src/form/src/form_value_wrapper.dart b/lib/src/form/src/form_value_wrapper.dart index ea48534..3c5e96d 100644 --- a/lib/src/form/src/form_value_wrapper.dart +++ b/lib/src/form/src/form_value_wrapper.dart @@ -110,7 +110,7 @@ class _FormValueWrapperState extends State> { builder: (BuildContext context, AsyncSnapshot<(String, bool)> validationSnapshot) { return widget.builder(widget.controller.getValue(widget.id), validationSnapshot.hasData && validationSnapshot.data != null && validationSnapshot.data!.$1 == widget.id && validationSnapshot.data!.$2 ? true : false, (T newValue, bool isRequired) { - return widget.controller.setValue(widget.id, (newValue, isRequired)); + return widget.controller.setValue(widget.id, newValue,isRequired: isRequired); }); }); //!SECTION