formatKey function
Formats the serialised key into a readable [ "user", "42" ] form.
Implementation
String formatKey(String rawKey) {
try {
final decoded = jsonDecode(rawKey) as List<dynamic>;
final parts = decoded.map((e) => e is String ? '"$e"' : '$e').join(', ');
return '[ $parts ]';
} catch (_) {
return rawKey; // fallback if not valid JSON
}
}