title: Flutter Exception caught by gesture. No MediaQuery widget found inside showModalBottomSheet
body: <p>Why I can't use showModalBottomSheet inside floatingActionButton? It just keeps showing me this error:</p>
  <pre><code>I/flutter (16368): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
  I/flutter (16368): The following assertion was thrown while handling a gesture:
  I/flutter (16368): No MediaQuery widget found.
  I/flutter (16368): MyApp widgets require a MediaQuery widget ancestor.
  I/flutter (16368): The specific widget that could not find a MediaQuery ancestor was:
  I/flutter (16368):   MyApp
  I/flutter (16368): The ownership chain for the affected widget is: &quot;MyApp ← [root]&quot;
  I/flutter (16368): Typically, the MediaQuery widget is introduced by the MaterialApp or WidgetsApp widget at the top of
  I/flutter (16368): your application widget tree.
  I/flutter (16368): 
  I/flutter (16368): When the exception was thrown, this was the stack:
  I/flutter (16368): #0      debugCheckHasMediaQuery.&lt;anonymous closure&gt; (package:flutter/src/widgets/debug.dart:211:7)
  I/flutter (16368): #1      debugCheckHasMediaQuery (package:flutter/src/widgets/debug.dart:223:4)
  I/flutter (16368): #2      showModalBottomSheet (package:flutter/src/material/bottom_sheet.dart:469:10)
  I/flutter (16368): #3      _MyAppState.build.&lt;anonymous closure&gt; (package:flutter_happy_habits/main.dart:32:29)
  I/flutter (16368): #4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
  </code></pre>
  <pre><code>import 'package:flutter/material.dart';
  import './models/home.dart';
  import 'models/progress.dart';
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatefulWidget {
    @override
    _MyAppState createState() =&gt; _MyAppState();
  }
  
  class _MyAppState extends State&lt;MyApp&gt; {
    int _selectedPage = 0;
    final _pageOptions = [
      Home(),
      Progress(),
      Progress(),
    ];
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        debugShowCheckedModeBanner: true,
        home: new Scaffold(
          appBar: AppBar(title: Text('Flutter Demo')),
          body: _pageOptions[_selectedPage],
          floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
          floatingActionButton: FloatingActionButton(
            child: Icon(Icons.add),
            onPressed: () { showModalBottomSheet(
              context: context,
              builder: (context) {
                return Text('Modal bottom sheet', style: TextStyle(fontSize: 30));
              });
            }
          ),
          bottomNavigationBar: BottomAppBar(
            shape: CircularNotchedRectangle(),
            notchMargin: 4.0,
            child: new Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: &lt;Widget&gt;[
                IconButton(
                  icon: Icon(Icons.home),
                  onPressed: () {
                    print(&quot;Home&quot;);
                    setState(() {
                      _selectedPage = 0;
                    });
                  },
                ),
                IconButton(
                  icon: Icon(Icons.insert_chart),
                  onPressed: () {
                    print(&quot;Progress&quot;);
                    setState(() {
                      _selectedPage = 1;
                    });
                  },
                ),
              ],
            ),
          ),
        ),
      );
    }
  }
  </code></pre>