containerContent method

void containerContent(
  1. List<String> level
)

Implementation

void containerContent(List<String> level) {
  correct = 0; //set no feedback icon.
  //fill containers with content
  for (int i = 0; i < containers.length; i++) {
    //let all containers be the same from start of levels.
    containers[i] = 'packages/cognition_package/assets/images/nothing.png';
  }
  tempMatch = level[_random.nextInt(level.length)]; //fill object with content
  List<int> containing = []; //list of containers that already has content
  int chosenContainer =
      _random.nextInt(containers.length); //container to fill with content

  for (int i = 0; i < level.length; i++) {
    //for every possible shape, fill a container with it
    while (containing.contains(chosenContainer)) {
      //be sure not to fill same containers
      chosenContainer =
          _random.nextInt(containers.length); //choose random containers
    }
    containing.add(
        chosenContainer); //add to keep track of containers with altered content
    containers[chosenContainer] = level[i]; //apply change to containers
  }
}