File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ dogs.registerTreeBaseFactory(
9292
9393You can register a custom tree base factory using the ` registerTreeBaseFactory ` method of the ` DogEngine ` .
9494
95+
9596``` { .dart title="Map Converter using NTreeArgConverter" }
9697final mapFactory = TreeBaseConverterFactory.createNargsFactory<Map>(
9798 nargs: 2, consume: <K, V>() => MapNTreeArgConverter<K, V>()
@@ -115,6 +116,13 @@ class MapNTreeArgConverter<K,V> extends NTreeArgConverter<Map> {
115116 }
116117}
117118```
119+
120+ !!! warning "Don't use Type Constraints"
121+ Since tree converters are dynamic in nature, they cannot statically enforce type constraints on their type arguments,
122+ as this would require down-casting type constraints at runtime, which is not possible in Dart.
123+
124+ If type constraints are required, consider performing runtime checks inside the converter methods.
125+
118126` NTreeArgConverters ` are used to convert complex types that have a fixed number of type arguments.
119127The consume method is used to expand the stored type arguments to usable generic type arguments
120128which then need to be used to create a NTreeArgConverter. The ` NTreeArgConverter ` class provides
You can’t perform that action at this time.
0 commit comments