toString method
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse
function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString
to provide
useful information when inspecting the object,
mainly for debugging or logging.
Implementation
@override
String toString() {
return '''BindingCastException: The widget ${field.runtimeType} bound to "${field.formControlName}" control
is expecting a "FormControl<$T>" data type,
but received a "${control.runtimeType}" data type.
This is caused because the template data type declared in the widget "${field.runtimeType}"
is not a 'subtype' of the template data type declared in the control "${control.runtimeType}".
To fix the error:
1- Explicitly set the data type of the control in its declaration.
Example:
{ '${field.formControlName}': FormControl<$T>(), }
2- If you are using the syntax: "{ '${field.formControlName}': [], }"
Then you should initialize the control with a default value (not-null) or use "fb.control"
to explicitly set a data type.
Examples:
1. Set a not-null default value
{ 'control': [''], } // the control is implicitly set to 'String' data type.
2. Set a not-null default value with "fb.control"
{ 'control': fb.control(''), } // the control is implicitly set to 'String' data type.
3. Set explicitly data type with "fb.control"
{ 'control': fb.control<String>(null), } // the control is explicitly set to 'String' data type.
''';
}