decode method
Implementation
LmNavigationState decode(Map<String, Object?> json) {
final encodedVersion = json['schemaVersion'];
if (encodedVersion != schemaVersion) {
throw LmRestoreException(
'Unsupported route state schema version $encodedVersion.',
);
}
final branchesJson = _asMap(json['branches'], 'branches');
return LmNavigationState(
activeBranchId: _asString(json['activeBranchId'], 'activeBranchId'),
branches: {
for (final entry in branchesJson.entries)
entry.key: _decodeBranch(entry.key, _asMap(entry.value, entry.key)),
},
location: _decodeLocation(_asString(json['location'], 'location')),
modalStack: [
for (final item in _asList(json['modalStack'], 'modalStack'))
_decodeModal(_asMap(item, 'modalStack item')),
],
version: _asInt(json['version'], 'version'),
);
}