One improvement that certainly comes to mind is the use of pictures instead of colors as shown in the Using images screenshot. How difficult would that be? It turns out that this is surprisingly easy, because we already have the game logic firmly in place!
Note
For the code files of this section, refer to chapter 7\educ_memory_game
in the code bundle. This is the master version of the game to be found in the root directory.
In the images
folder, we supply a number of game pictures. Instead of the color
property, we give the cell a String
property (image
), which will contain the name of the picture file. We then replace util\color.dart
with util\images.dart
, which contains an imageList
variable with the image filenames. In util\random.dart
, we will replace the color
methods with the following code:
String randomImage() => randomListElement(imageList);
The changes to memory.dart
are also straightforward: replace the usedColor
list with List usedImages = [];
and the _getFreeRandomColor...