title: Flutter call form save function from another file
body: <p>I have this event form, it's to create or edit events data. The save button is inside the app bar action, and the form is inside the body. In this project, I have all of the widgets in different files. How do I run the save function inside EventFormForm.dart when I tap the save button inside EventFromAppBar.dart?
  This is the structure :</p>
  <p><a href="https://i.stack.imgur.com/zjRDk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zjRDk.jpg" alt="enter image description here" /></a></p>
  <p>These are my codes :</p>
  <p>EventForm.dart</p>
  <pre><code>class EventForm extends StatelessWidget {
    // Some Code
  
    // Some Const
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: EventFormAppBar(
  // Some Params
  ),
        body: EventFormBody(
  // Some Params
  )
      );
    }
  }
  </code></pre>
  <p>EventFormAppBar.dart</p>
  <pre><code>class EventFormAppBar extends PreferredSize{
    // Some Code
  
    // Some Const
  
    // Some Code
  
    @override
    Widget build(BuildContext context) {
      return AppBar(
        // Some Code
        actions: &lt;Widget&gt;[
          IconButton(
            icon: Icon(Icons.save),
            onPressed: () {
  
            }
          )
        ]
      );
    }
  }
  </code></pre>
  <p>EventFormBody.dart</p>
  <pre><code>    class EventFormBody extends StatelessWidget {
        // Some Code
      
        // Some Const
      
        @override
        Widget build(BuildContext context) {
          return SafeArea(
            child: SingleChildScrollView(
              child: EventFormForm(
      // Some Params
      ),
            ),
          );
        }
      }
  
  EventFormForm.dart
  class EventFormForm extends StatefulWidget {
    // Some Code
  
    // Some Const
  
    @override
    EventFormFormState createState() =&gt; EventFormFormState();
  }
  
  class EventFormFormState extends State&lt;EventFormForm&gt; {
  //
  //
  // Some Code
  //
  //
  
  @override
    Widget build(BuildContext context) {
  return Form(
  //
  // Some Code
  //
  );
  }
  
  saveForm() {
  //
  // Some Code
  //
  }
  
  }
  </code></pre>
  <p>Tag @chunhunghan</p>