Placing the images of the actual pieces

After mapping the pieces to their initial positions, we can start placing actual image vectors:

  1. 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); ...

Get Mobile Deep Learning with TensorFlow Lite, ML Kit and Flutter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.