title: Flutter - Calling persistent bottom sheet from another class
body: <p>I have a persistent bottom sheet in Flutter which currently exists inside an icons <code>onPressed(){}</code> property.</p>
  
  <p>I would like to move this persistent bottom sheet to a new class on its own but I can't seem to get it working. I am still new to flutter and can't work out how to build the structure for the persistent bottom bar.</p>
  
  <p>I have currently tried the below but when I run my code, I get an exception that is thrown.  </p>
  
  <p>main.dart</p>
  
  <pre><code>@override
  Widget build(BuildContext context) {
  return Scaffold(
    key: _scaffoldKey,
    appBar: AppBar(
      title: Text('Test App'),
      actions: &lt;Widget&gt;[
        IconButton(
          icon: Icon(Icons.open_in_new),
          onPressed: (){
            ShowBottomSheet(context);
          },
        )
      ],
    ),
  </code></pre>
  
  <p>bottom_modal_sheet.dart</p>
  
  <pre><code>final GlobalKey&lt;ScaffoldState&gt; _scaffoldKey = new 
  GlobalKey&lt;ScaffoldState&gt;();
  
  void ShowBottomSheet(BuildContext context) {
    _scaffoldKey.currentState.showBottomSheet&lt;Null&gt;((BuildContext context) 
  {
  return new Container(
    width: double.infinity,
    child: new Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: &lt;Widget&gt;[
        Padding(
          padding: EdgeInsets.only(left: 24.0, top: 16.0),
          child: Text('Site Location',
            style: TextStyle(fontSize: 24.0, color: Color(0xFF1181A1), fontWeight: FontWeight.bold,),
          ),
        ),
        Padding(
          padding: EdgeInsets.only(left: 24.0, top: 16.0),
          child: Text('11 Carr Road, Three Kings, Auckland 1042',
            textAlign: TextAlign.left,
            style: TextStyle(fontSize: 16.0, color: Color(0xFF8596AC)),
          ),
        ),
        Padding(
          padding: EdgeInsets.only(left: 24.0, top: 24.0, right: 24.0, bottom: 16.0),
          child: RasiedGradientButton(
            child: Text('Set Location', style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.white)),
            gradient: LinearGradient(
              colors: &lt;Color&gt;[Color(0xFFFCCF58), Color(0xFFFEAA00)]
            ),
            onPressed: (){
              print('button clicked');
            },
          )  
        ),
      ],
  ));
    });
  }
  </code></pre>
  
  <p>I am getting the error: </p>
  
  <pre><code>I/flutter (19024): ══╡ EXCEPTION CAUGHT BY GESTURE 
  ╞═══════════════════════════════════════════════════════════════════
  I/flutter (19024): The following NoSuchMethodError was thrown while 
  handling a gesture:
  I/flutter (19024): The method 'showBottomSheet' was called on null.
  I/flutter (19024): Receiver: null
  I/flutter (19024): Tried calling: showBottomSheet&lt;Null&gt;(Closure: 
  (BuildContext) =&gt; Container)
  I/flutter (19024): 
  </code></pre>