This commit is contained in:
2025-03-23 16:22:19 +02:00
parent 0b221db241
commit 114f0133b0
2 changed files with 7 additions and 2 deletions

View File

@@ -97,7 +97,12 @@ class AstromicFormController extends FormController {
/// Get the value of a hosted state variable using it's ID. /// Get the value of a hosted state variable using it's ID.
T? getValue<T>(String id) { T? getValue<T>(String id) {
prepareValue(id, false); 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 @override

View File

@@ -110,7 +110,7 @@ class _FormValueWrapperState<T> extends State<FormValueWrapper<T>> {
builder: (BuildContext context, AsyncSnapshot<(String, bool)> validationSnapshot) { builder: (BuildContext context, AsyncSnapshot<(String, bool)> validationSnapshot) {
return widget.builder(widget.controller.getValue<T>(widget.id), return widget.builder(widget.controller.getValue<T>(widget.id),
validationSnapshot.hasData && validationSnapshot.data != null && validationSnapshot.data!.$1 == widget.id && validationSnapshot.data!.$2 ? true : false, (T newValue, bool isRequired) { 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 //!SECTION