title: Flutter : icon != null is not true
body: <p>I dont know why I am getting error when I add this code to <code>GridView.count</code> Widget </p>
  
  <p>the added code is  :</p>
  
  <pre><code>buildTile(context,1,'Conselors',null,Icons.person,'Contact with the',Colors.green,Colors.green[50]),
  </code></pre>
  
  <p>Error code is :</p>
  
  <pre><code>The following assertion was thrown building Home(dirty, dependencies: [MediaQuery], state:
  I/flutter ( 6241): HomeScreen#1419b):
  I/flutter ( 6241): 'package:flutter/src/material/icon_button.dart': Failed assertion: line 159 pos 15: 'icon != null':
  I/flutter ( 6241): is not true.
  I/flutter ( 6241): 
  I/flutter ( 6241): Either the assertion indicates an error in the framework itself, or we should provide substantially
  I/flutter ( 6241): more information in this error message to help you determine and fix the underlying cause.
  </code></pre>
  
  <p>Full code is :</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:percent_indicator/percent_indicator.dart';
  
  class Home extends StatefulWidget {
  
    @override
    HomeScreen createState() =&gt; HomeScreen();
  }
  
  class HomeScreen extends State&lt;Home&gt; {
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
          backgroundColor: Colors.white,
          resizeToAvoidBottomPadding: false,
          body: ListView(
            children: &lt;Widget&gt;[
              Stack(
                children: &lt;Widget&gt;[
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: &lt;Widget&gt;[
                      SizedBox(height: 20),
                      Container(
                          padding: EdgeInsets.fromLTRB(12, 0, 12, 0),
                          child: Center(
                            child: Text(
                              "The best application for gudance ",
                              style: TextStyle(
                                  fontSize: 20, fontWeight: FontWeight.bold),
                            ),
                          )),
                      SizedBox(height: 12),
                      Container(
                          child: LinearPercentIndicator(
                            padding: EdgeInsets.fromLTRB(17, 0, 20, 0),
                            fillColor: null,
                            progressColor: Colors.blue,
                            percent: 1,
                            width: MediaQuery.of(context).size.width,
                            lineHeight: 3,
                            backgroundColor: Colors.grey[200],
                          )),
                      SizedBox(
                        height: 12,
                      ),
                      Container(
                        height: MediaQuery.of(context).size.height * 1,
                        child: buildGrid(context),
                      ),
                      SizedBox(
                        height: 12,
                      ),
                      Container(
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(10),
                            gradient: LinearGradient(
                                begin: Alignment.topLeft,
                                end: Alignment.bottomRight,
                                colors: [
                                  Colors.blue[600],
                                  Colors.blue[500],
                                  Colors.blue,
                                  Colors.blue[400],
                                  Colors.blue[300]
                                ])),
                        margin: EdgeInsets.only(left: 12, right: 12),
                      )
                    ],
                  )
                ],
              )
            ],
          ));
    }
  
    @override
    Widget buildGrid(BuildContext context) {
      return GridView.count(
        padding: EdgeInsets.fromLTRB(0, 5, 0, 5),
        crossAxisCount: 2,
        shrinkWrap: true,
        childAspectRatio: (MediaQuery.of(context).size.width - 60 / 2) / 300,
        children: &lt;Widget&gt;[
          buildTile(context, 0, "Library", null, Icons.local_library, "Google Books",
              Colors.blue, Colors.blue[50]),
          buildTile(context,1,'Conselors',null,Icons.person,'Contact with the',Colors.green,Colors.green[50]),
  
        ],
      );
    }
  
    int _selectedIndex = -1;
  
    @override
    Widget buildTile(BuildContext context, int index, String heading, Image image,
        IconData icon, String itemCount, Color color, Color backgroundColor) {
      return Container(
        padding: EdgeInsets.only(
            left: index == 0 || index == 2 || index == 4 ? 12 : 5,
            top: 0,
            right: index == 1 || index == 3 || index == 5 ? 12 : 5,
            bottom: 10),
        decoration: BoxDecoration(
            color: Colors.white, borderRadius: BorderRadius.circular(10)),
        child: GestureDetector(
          onTap: () {
            setState(() {
              _selectedIndex = index;
            });
            switch(index){
              case 0 :
                print('its index 0');
                break;
              case 1 :
                print('its index 1');
                break;
              case 2 :
                print('its index 2');
                break;
            }
          },
          child: Card(
              elevation: 3,
              shape: RoundedRectangleBorder(
                  side: BorderSide(
                      width: 1.0,
                      style: BorderStyle.solid,
                      color: _selectedIndex == index &amp;&amp; color != null
                          ? color
                          : Colors.white),
                  borderRadius: BorderRadius.circular(10)),
              color: Colors.white,
              child: Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: &lt;Widget&gt;[
                      Stack(
                        alignment: Alignment(0, 0),
                        children: &lt;Widget&gt;[
                          Container(
                            width: 43,
                            height: 43,
                            decoration: BoxDecoration(
                                color: backgroundColor,
                                borderRadius: BorderRadius.circular(15)),
                          ),
                          index == 1
                              ? IconButton(
                            icon: image,
                            onPressed: () {},
                          )
                              : Icon(
                            icon,
                            color: color,
                          ),
                          index != 1
                              ? SizedBox(
                            height: 4,
                          )
                              : SizedBox(
                            height: 0,
                          ),
                        ],
                      ),
                      Text(
                        heading,
                        style: TextStyle(
                            color: Colors.black,
                            fontSize: 18,
                            fontWeight: FontWeight.w600),
                      ),
                      SizedBox(
                        height: 4,
                      ),
                      Text(
                        itemCount,
                        style: TextStyle(
                            color: Colors.grey,
                            fontSize: 12,
                            fontWeight: FontWeight.w300),
                      )
                    ],
                  ))),
        ),
  //      ),
      );
    }
  }
  </code></pre>