0

I have a nested Map that's look like this :

{users: {1: {id: 1, name: Bill, date: 2020-01-01 00:00:00.000Z}}}

I want access to the name

array["users"]["1"]["name"]

This is working fine. But I want to do it "dynamically", like something :

final path = "users,1,name";
array[path];

Is there a way to do that in Dart ?

1 Answer 1

1

Maybe this way:

final path = 'users,1,name';
final parts = path.split(',');
print(array[parts[0]][parts[1]][parts[2]]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.