Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine lists and enums #220

Open
gregorscholz opened this issue May 29, 2024 · 3 comments
Open

Combine lists and enums #220

gregorscholz opened this issue May 29, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@gregorscholz
Copy link

Motivation
I want to use lists from a csv in combination with a custom enum.

E.g: I have multiple sets of instruction with a different number of steps. In code i want to access it like this:

final instructions = t.instructions(context: level);
...
List.generate(instructions.length, (index) => Text(instructions[index])),
@gregorscholz gregorscholz added the enhancement New feature or request label May 29, 2024
@Tienisto
Copy link
Member

Tienisto commented May 29, 2024

You can specify lists in csv by adding numbers to the key:

instructions.beginner.0,First Step
instructions.beginner.1,Second Step

@gregorscholz
Copy link
Author

gregorscholz commented May 29, 2024

Thank you for the quick response, but this can not be used in combination with enums. I get the following error:

Unhandled exception:
The leaf "instructions(context=Level).beginner.1" cannot be added because there are missing indices.

This is my csv entry

instructions(context=Level).beginner.1,first step,first step

@gregorscholz
Copy link
Author

Ok i guess this problem occured because i started with 1, my bad...

But still i get an error.

Unhandled exception:
type 'ListNode' is not a subtype of type 'StringTextNode' in type cast

when this is the complete csv

key,de,en
instructions(context=Level).beginner.0,first step, first step
instructions(context=Level).beginner.1,sec step, sec step

@Tienisto Tienisto changed the title Lists in csv Combine lists and enums May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants