Closed
Description
const tree=(
a:"/a",
b:"/b",
c:(
a:"/c/a",
b:"/c/b",
),
);
make records work same as a Map?
print(tree.keys);// [a,b,c]
print(tree["a"]);// "/a"
or may be like a array?
print(tree.length);// 3
print(tree.$1);// /a
print(tree[0]);// /a
I Read #2673 , but,I don't know how enum.values do it. Can it be implemented similarly?
This is very useful for implementing static variable trees,
now dart is very inconvenient,like this:
N<void> root = N<void>("/", meta: rootPage, kids: [
N<void>("not_found", meta: notFoundPage),
N<void>("note", meta: notePage, kids: [
N<void>("material", kids: [
]),
]),
]);
N page(path) => root.kid(path);
class Paths {
final N<void> home = page("/");
final N<void> notFound = page("/not_found");
final N<void> note = page("/note");
final N<void> note_material = page("/note/material");
Paths._();
}
var paths = Paths._();