0

How to insert String array to list object / list model?

My result String array:

[198507282014041001, 199001312019031018, 199112212019031014, 197710232002121001]

I wanna add my string to my model, this my model:

class Tag {
  final String id;

  Tag(this.id);
}

1 Answer 1

1

Try the following code:

List<String> stringList = [
  "198507282014041001",
  "199001312019031018",
  "199112212019031014",
  "197710232002121001",
];

List<Tag> tagList = stringList.map((e) => Tag(e)).toList();

print(tagList.map((e) => e.id).toList()); // Check if there is already data in the model
Sign up to request clarification or add additional context in comments.

1 Comment

how we know the data is already inside the model?

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.