title: flutter not rendering when color changes
body: <p>I am new to flutter/dart. I have written an app that displays tiles in a GridView. Each tile is numbered and colored and is assigned an onTap handler. The onTap handler is to debugPrint the index of the tile and invoke setState(). setState() is expected to force the re-rendering of the GridView with the tapped tile displayed in Color.white.</p>
  
  <p>When executed in debug mode, the display on the device is as expected. When a tile is tapped, the debugPrint message is displayed in the DEBUG CONSOLE, but the color of the tapped tile does not change to Color.white.</p>
  
  <p>I have examined the tiles when they are regenerated (when a tile has been tapped). As expected, all of the untapped tiles are assigned their original tile colors. The tapped tile is assigned Color.white. But the change in tile color (i.e., the tapped tile color change from its original color to Color.white) appears not to be detected and the app does not redraw with one white tile.</p>
  
  <p>The app code follows. Please advise what I am doing wrong.</p>
  
  <pre><code>// ignore_for_file: camel_case_types
  // ignore_for_file: constant_identifier_names
  // ignore_for_file: non_constant_identifier_names
  
  import 'package:flutter/material.dart';
  
  const List _normal_colors = [
    Colors.indigo,
    Colors.green,
    Colors.amber,
    Colors.orange,
    Colors.red,
    Colors.blue,
    Colors.cyan,
    Colors.yellow,
    Colors.purple,
  ]; // _normal_colors
  
  void main() =&gt; runApp(new MyApp());
  
  class Tiled_Surface extends StatefulWidget {
    Tiled_Surface({Key key}) : super(key: key);
  
    @override // Tiled_Surface
    Tiled_Surface_State createState() =&gt; Tiled_Surface_State();
  }
  
  class Tiled_Surface_State extends State&lt;Tiled_Surface&gt; {
    List&lt;GridTile&gt; _grid_tiles = &lt;GridTile&gt;[];
    int _tapped = -1;
  
    void on_tile_tapped(int index) {
      debugPrint("You tapped on item $index");
      setState(() {
        _tapped = index;
      });
    } // on_tile_tapped
  
    GridTile new_surface_tile(Color tile_color, int index) {
      GridTile tile = GridTile(
        child: GestureDetector(
          onTap: () =&gt; on_tile_tapped(index),
          child: Container(
            child: Center(
              child: Text (
                index.toString(),
                style: TextStyle(
                  fontSize: 24.0,
                  color: _tapped == index ?
                             Colors.black :
                             Colors.white,),
              )
            ),
            decoration: BoxDecoration(
              color: _tapped == index ?
                         Colors.white :
                         tile_color,
              shape: BoxShape.rectangle,
            ),
          ),
        )
      );
    return (tile);
    } // new_surface_tile
  
    List&lt;GridTile&gt; surface_tiles(colors) {
      _grid_tiles.clear();
      for (int i = 0; (i &lt; colors.length); i++) {
        _grid_tiles.add(new_surface_tile(colors[i], i));
      }
      return (_grid_tiles);
    } // surface_tiles
  
    @override // Tiled_Surface_State
    Widget build(BuildContext context) {
      return GridView.count(
        shrinkWrap: true,
        crossAxisCount: 3,
        childAspectRatio: 1.0,
        padding: const EdgeInsets.all(4.0),
        mainAxisSpacing: 4.0,
        crossAxisSpacing: 4.0,
        children: surface_tiles(_normal_colors),
      );
    }
  } // class Tiled_Surface_State
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      Widget tiled_surface = Container(
        child: Column(
          children: [
            Tiled_Surface(),
          ],
        ),
      );
  
      return MaterialApp(
        title: 'Tiled Surface Demo',
        home: Scaffold(
          appBar: AppBar(title: Text('Tiled Surface Demo'),
                         actions: &lt;Widget&gt;[
            IconButton(
              tooltip: "Replay",
              icon: Icon(Icons.replay),
              onPressed: () {
  // TODO       _reinitialize_tiles ( );
              },
            ),
          ] ),
          body: Column(
            children: [
              tiled_surface,
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>This question differs from that of the recommended answer in that this deals with a private class of ListView while this question deals with a GridView.</p>