title: Flutter : Get AlertDialog From Another Dart File
body: <p>i need help guys.
  I have 2 dart file : main.dart and alertform.dart. some cases require using this method in my application.
  I want to try accessing the alerdialog from alertform.dart on the button on main.dart. is that possible? this my code:</p>
  
  <p>main.dart</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'alertform.dart';
  
  class MainPage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: new Text('Test'),
        ),
        body: new Column(
          children: &lt;Widget&gt;[
            RaisedButton(
              child: new Text('Show Alert'),
              onPressed: (){
                CommentForm();
              },
            )
          ],
        ),
      );
    }
  }
  </code></pre>
  
  <p>alertform.dart</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class AlertForm extends StatefulWidget {
    @override
    _AlertFormState createState() =&gt; _AlertFormState();
  }
  
  class _AlertFormState extends State&lt;AlertForm&gt; {
  
      void _showDialog() {
      // flutter defined function
      showDialog(
        context: context,
        builder: (BuildContext context) {
          // return object of type Dialog
          return AlertDialog(
            title: new Text("Alert Dialog title"),
            content: new Text("Alert Dialog body"),
            actions: &lt;Widget&gt;[
              // usually buttons at the bottom of the dialog
              new FlatButton(
                child: new Text("Close"),
                onPressed: () {
                  Navigator.of(context).pop();
                },
              ),
            ],
          );
        },
      );
    }
  
  
    @override
    Widget build(BuildContext context) {
      return Container(
  
      );
    }
  }
  </code></pre>