You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I would like to introduce a humble suggestion, regarding returned errors from models.dart
someControl.setErrors(<String, dynamic>{ ...someControl.errors ..removeWhere((key, value) => key == errorMessageKey), });
When used like that it causes exception due to unmodifiable Map returned.
Wouldn't it be more convenient to return copy of the map: Map<String, Object> get errors => Map<String, Object>.from(_errors);
instead of: Map<String, Object> get errors => Map<String, Object>.unmodifiable(_errors);
P.S. Yeah, I am aware now of someControl(errorMessageKey); but only after this error of mine was merged)
The text was updated successfully, but these errors were encountered:
Thanks for your feedback. I see what's your point, and it makes sense. I believe the initial idea of using unmodifiable collections was to remove the false impression that someone could change the original collection of errors. On the other hand you can also create a copy of the errors, and that will solve your problem. This would do the trick:
final myErrors = {...control.errors}..removeWhere((key, value) => key == errorMessageKey);
Hi, I would like to introduce a humble suggestion, regarding returned errors from models.dart
someControl.setErrors(<String, dynamic>{ ...someControl.errors ..removeWhere((key, value) => key == errorMessageKey), });
When used like that it causes exception due to unmodifiable Map returned.
Wouldn't it be more convenient to return copy of the map:
Map<String, Object> get errors => Map<String, Object>.from(_errors);
instead of:
Map<String, Object> get errors => Map<String, Object>.unmodifiable(_errors);
P.S. Yeah, I am aware now of
someControl(errorMessageKey);
but only after this error of mine was merged)The text was updated successfully, but these errors were encountered: