switch_when library Null safety

Functions

when<T>(Map<bool, ValueGetter<T>> conditionMap) → T?
English: The when function of the Kotlin version of the method switch.
As long as the first true is found in Map.keys of conditionMap, its corresponding ValueGetter method will be executed immediately and the relative value will be returned.
If it is not found, it will return null; if you need a default value, you can add a MapEntry with a key equal to true at the end of the Map
whenBool<T>(bool value, List<Tuple2<bool, ValueGetter<T>>> conditionList) → T?
English: Used to replace the switch method, because some scenes use switch to cause an error warning of Case expressions must be constant.
If there is value in Tuple2.item1 of conditionList, execute its corresponding ValueGetter method
whenBoolSafe<T>(bool value, List<Tuple2<bool, ValueGetter<T>>> conditionList, {ValueGetter<T>? defaultValue}) → T?
English: Used to replace the switch method, because some scenes use switch to cause an error warning of Case expressions must be constant.
If there is value in Tuple2.item1 of conditionList, execute its corresponding ValueGetter method
whenDouble<T>(double value, Map<double, ValueGetter<T>> conditionMap) → T?
English: Used to replace the switch method, because in some scenarios, an error warning of Case expressions must be constant;
If there is value in Map.keys of conditionMap, execute its corresponding ValueGetter method
whenDoubleSafe<T>(double value, Map<double, ValueGetter<T>> conditionMap, {ValueGetter<T>? defaultValue}) → T
English: Used to replace the switch method, because in some scenarios, an error warning of Case expressions must be constant;
If there is value in Map.keys of conditionMap, execute its corresponding ValueGetter method
whenInt<T>(int value, Map<int, ValueGetter<T>> conditionMap) → T?
English: Used to replace the switch method, because in some scenarios, an error warning of Case expressions must be constant;
If there is value in Map.keys of conditionMap, execute its corresponding ValueGetter method
whenIntSafe<T>(int value, Map<int, ValueGetter<T>> conditionMap, {ValueGetter<T>? defaultValue}) → T
English: Used to replace the switch method, because in some scenarios, an error warning of Case expressions must be constant;
If there is value in Map.keys of conditionMap, execute its corresponding ValueGetter method
whenSafe<T>(Map<bool, ValueGetter<T>> conditionMap, {ValueGetter<T>? defaultValue}) → T
English: The when function of the Kotlin version of the method switch.
As long as the first true is found in Map.keys of conditionMap, its corresponding ValueGetter method will be executed immediately and the relative value will be returned.
If it is not found, you must set defaultValue, or use the when method
whenString<T>(String value, Map<String, ValueGetter<T>> conditionMap) → T?
English: Used to replace the switch method, because in some scenarios, an error warning of Case expressions must be constant;
If there is value in Map.keys of conditionMap, execute its corresponding ValueGetter method
whenStringSafe<T>(String value, Map<String, ValueGetter<T>> conditionMap, {ValueGetter<T>? defaultValue}) → T
English: Used to replace the switch method, because in some scenarios, an error warning of Case expressions must be constant;
If there is value in Map.keys of conditionMap, execute its corresponding ValueGetter method
whenTrue<T>(Map<ValueGetter<bool>, ValueGetter<T>> conditionMap) → T?
English: The when function of the Kotlin version of the method switch,its conditional expression will be calculated。.
As long as conditionMap to Map.keys appears first execution result is true, it will immediately perform corresponding ValueGetter method, and an opposite return value.
If it is not found, it will return null; if you need a default value, you can add a MapEntry with a key equal to true at the end of the Map
whenTrueSafe<T>(Map<ValueGetter<bool>, ValueGetter<T>> conditionMap, {ValueGetter<T>? defaultValue}) → T
English: The when function of the Kotlin version of the method switch,its conditional expression will be calculated。.
As long as conditionMap to Map.keys appears first execution result is true, it will immediately perform corresponding ValueGetter method, and an opposite return value.
If it is not found, it will return null; if you need a default value, you can add a MapEntry with a key equal to true at the end of the Map
whenValue<V, T>(V value, Map<V, ValueGetter<T>> conditionMap) → T?
English: The super evolution version💖💖💖 of switch method, all basic types of values can be compared, including List, Map, Set, and Iterable.
All need do is value in Map.keys of conditionMap, its corresponding ValueGetter method will be executed
whenValueSafe<V, T>(V value, Map<V, ValueGetter<T>> conditionMap, {ValueGetter<T>? defaultValue}) → T
English: The super evolution version💖💖💖 of switch method, all basic types of values can be compared, including List, Map, Set, and Iterable.
All need do is value in Map.keys of conditionMap, its corresponding ValueGetter method will be executed