title: Snackbar doesn't show up if onPressed has more code in it
body: <p>At first I encountered the issue that the <code>Scaffold.of(context)</code> referred to the wrong context. I implemented the <code>Builder</code> widget properly. The error message was gone but the snackbar still doesn't show up. My first thought was that I've done something wrong and tried the other way around and set a key to the <code>Scaffold</code>.
  All this referring to the examples and explanations of this thread which definitely make sense: <a href="https://stackoverflow.com/questions/53922053/how-to-properly-display-a-snackbar-in-flutter">How to properly display a Snackbar in Flutter?</a></p>
  
  <p>But nothing of this worked. I was wondering why so I tried a little bit around and found out that the Snackbar works when i remove all the other function calls in my <code>onPressed</code> function of the button</p>
  
  <pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';
  import 'package:flutter_complete_guide/providers/cart_provider.dart'
      show CartProvider;
  import 'package:flutter_complete_guide/providers/order_provider.dart';
  //import 'package:flutter_complete_guide/screens/order_screen.dart';
  import 'package:flutter_complete_guide/widgets/cart_item.dart';
  import 'package:provider/provider.dart';
  
  class CartScreen extends StatelessWidget {
    static const routeName = "/cart";
  
    @override
    Widget build(BuildContext context) {
      final cart = Provider.of&lt;CartProvider&gt;(context);
      final _scaffoldKey = GlobalKey&lt;ScaffoldState&gt;();
  
      return Scaffold(
        key: _scaffoldKey,
        appBar: AppBar(
          title: Text("Your Cart"),
        ),
        body: Builder(
          builder: (BuildContext context) =&gt; Column(
            children: &lt;Widget&gt;[
              Card(
                margin: EdgeInsets.all(15.0),
                child: Padding(
                  padding: EdgeInsets.all(8.0),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: &lt;Widget&gt;[
                      Text(
                        "Total",
                        style: TextStyle(fontSize: 20.0),
                      ),
                      SizedBox(width: 10),
                      Spacer(),
                      Chip(
                        label: Text("\$${cart.totalAmount}"),
                        backgroundColor: Theme.of(context).primaryColor,
                      ),
                      FlatButton(
                        onPressed: () {
                          Scaffold.of(context).showSnackBar(
                            SnackBar(
                              content: Text("Test Snackbar"),
                            ),
                          );
                          /*
                          ** If this code gets called, the snackbar does not work anymore **
                          Provider.of&lt;OrderProvider&gt;(context, listen: false)
                              .addOrder(
                                  cart.items.values.toList(), cart.totalAmount);
                          cart.clear();
                          */
                        },
                        child: Text("Order now"),
                      ),
                    ],
                  ),
                ),
              ),
              SizedBox(height: 10),
              Expanded(
                child: ListView.builder(
                  itemCount: cart.items.length,
                  itemBuilder: (ctx, index) =&gt; CartItem(
                    id: cart.items.values.toList()[index].id,
                    productId: cart.items.keys.toList()[index],
                    title: cart.items.values.toList()[index].title,
                    price: cart.items.values.toList()[index].price,
                    quantity: cart.items.values.toList()[index].quantity,
                  ),
                ),
              ),
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>The strange part about that is, I've added another snackbar to another Button and in that <code>onPressed</code> is another function call aswell but this works perfectly fine:</p>
  
  <pre class="lang-dart prettyprint-override"><code>IconButton(
              icon: Icon(Icons.shopping_cart),
              onPressed: () {
                cart.addItem(products.id, products.price, products.title);
                Scaffold.of(context).hideCurrentSnackBar();
                Scaffold.of(context).showSnackBar(
                  SnackBar(
                    content: Text("${products.title} added"),
                    duration: Duration(seconds: 1),
                    action: SnackBarAction(
                      label: "UNDO",
                      onPressed: () =&gt; cart.removeItemSignle(products.id),
                    ),
                  ),
                );
              },
  </code></pre>
  
  <p>I clearly have no clue whats going wrong here, does anyone have an idea?</p>