config property
Per-instance configuration, handed to the GUI-side implementation. Must be JSON-encodable — it crosses a process boundary.
Implementation
@override
Map<String, Object?> get config {
// A world is opened by its file's name — `worlds open --world=…` — so two
// of one name would be one world written twice.
var seen = <String, String>{};
for (var package in packages) {
for (var world in package.worlds) {
if (seen[world.id] case var other?) {
throw StateError(
'Two worlds are called "${world.id}": ${world.path} in '
'"${package.path}" and one in "$other". A world is opened by its '
"file's name, so rename one of the files.",
);
}
seen[world.id] = package.path;
}
}
return {
'packages': [for (var p in packages) p.toJson()],
};
}