Skip to content

Commit 587adf7

Browse files
author
travis
committed
docs: add flexibleMap and flexibleMapNotNull functions to README
1 parent d86738d commit 587adf7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ Make sure to run your build runner after adding these annotations:
134134
- `String? flexibleUpperStringFromJson(dynamic value)`
135135
- Converts input to string, trims it, then converts to uppercase. Returns `null` if the trimmed string is empty.
136136

137+
- `Map<K, V>? flexibleMapFromJson<K, V>(dynamic value, MapEntry<K, V>? Function(dynamic key, dynamic value) mapper)`
138+
- Transforms a map by applying a transformation function to each key-value pair.
139+
- Handles `null` input by returning `null`.
140+
- The `mapper` function can return `null` to skip entries.
141+
- Example: Converts `{"a": "1", "b": "2"}` to `{"a": 1, "b": 2}` when used with `int.tryParse`.
142+
143+
- `Map<K, V> flexibleMapNotNullFromJson<K, V>(dynamic value, MapEntry<K, V>? Function(dynamic key, dynamic value) mapper)`
144+
- Similar to `flexibleMapFromJson` but returns an empty map instead of `null` for `null` input.
145+
- The `mapper` function can return `null` to skip entries.
146+
- Example: Converts `{"a": "1", "b": "x"}` to `{"a": 1}` when used with `int.tryParse`.
147+
137148
## Contributing
138149

139150
Feel free to open an issue or submit a pull request if you have suggestions or find bugs.

0 commit comments

Comments
 (0)