get<T> method
Extracts a single model value by a dot-notation path and tries to cast it to the specified generic type.
If explicitly set, returns defaultValue on missing path.
For more details about the casting rules, please refer to
caster.extract().
Example:
final data = {"a": {"b": [{"b1": 1}, {"b2": 2}, {"b3": 3}]}};
final field = CollectionField(data);
final result0 = field.get<int>("a.b.c", 999); // 999
final result1 = field.get<int>("a.b.2.b3"); // 3
final result2 = field.get<String>("a.b.2.b3"); // "3"
Implementation
T get<T>(String fieldNameOrPath, [T? defaultValue]) {
return caster.extract<T>(data, fieldNameOrPath, defaultValue);
}