After mapping the pieces to their initial positions, we can start placing actual image vectors:
- We begin by defining a function called mapImages() that takes the index of the square, that is, the key value of the hashmap board, and returns the image:
Widget mapImages(String squareName) { board.putIfAbsent(squareName, () => " "); String p = board[squareName]; var size = 6.0; Widget imageToDisplay = Container(); switch (p) { case "P": imageToDisplay = WhitePawn(size: size); break; case "R": imageToDisplay = WhiteRook(size: size); break; case "N": imageToDisplay = WhiteKnight(size: size); break; case "B": imageToDisplay = WhiteBishop(size: size); break; case "Q": imageToDisplay = WhiteQueen(size: size); ...