flat
0.5.0, released 3 years ago by an unverified publisher
Zero-dependency package to flatten nested Maps and recover them later.
WASM-ready
What it does
It converts a deeply nested Map and flattens it into a single-depth Map with delimited keys. It also provides an unflatten method to reverse the process.
AI-written summary of version 0.5.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to flatten nested maps for database storage or query parameters
- You want to convert nested JSON structures into single-depth key-value pairs
Skip it when
- You need feature parity with the full Node.js flat package (such as transformKey)
- Your tree contains types other than Map or List during flattening
Strengths
- Zero dependencies
- Supports custom delimiters, safe mode for arrays, and maxDepth configuration
- Supports null safety and Map<String, dynamic>
Weaknesses
- Does not achieve full feature parity with the Node.js flat package
- Bails out of a tree if it encounters something other than a Map or List
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:flat/flat.dart';
final flattened = flatten({
"a": 1,
"f": {
"g": 2,
},
});Alternatives
Packages that do the same job and could replace flat.
- hex
Provides simple HEX.encode and HEX.decode functions for converting between byte lists and hexadecimal strings.
47Compare - string_to_color
Convert strings to colors, hex strings, or hex integers in Dart and Flutter.
42Compare