1

if I have this List in Flutter :

var myList = ["a","b" , "c" , "d"];

How to create new list from myList by random index for each value like :

   ["b","c" , "a" , "d"];

or :

   ["a","c" , "d" , "b"];

or any other random list

3 Answers 3

2
var newList = [...myList];
newList.shuffle();
Sign up to request clarification or add additional context in comments.

Comments

1
import random

myList = ["a","b" , "c" , "d"];
random.shuffle(myList)

print(mylist)

You follow this https://www.w3schools.com/python/ref_random_shuffle.asp

1 Comment

this is for python ,I need in dart
0

Try this:

var myList = ["a", "b", "c", "d"];
myList.shuffle();

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.