title: How do I navigate from one activity to another in flutter
body: <p>Hi I am pretty new to flutter and software development in general. I can't seem to understand how do I navigate from one activity to another.
  What I really want is when I press the login button it should navigate me to a new activity</p>
  <pre><code>void main() {
    runApp(MaterialApp(
      title: 'button navigation',
      home: HomeActivity(),
    ));
  }
  
  class HomeActivity extends StatelessWidget{
    gotoSecondActivity(BuildContext context){
  
      Navigator.push(
        context,
        MaterialPageRoute(builder: (context) =&gt; SecondActivity()),
      );
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text('Home Screen'),
        ),
  
        body: Center(
          child: RaisedButton(
            child: Text('Go To Second Screen'),
            color: Colors.red,
            textColor: Colors.white,
            onPressed: () {
              gotoSecondActivity(context);
            },
          ),
        ),
      );
    }
  }
  class SecondActivity extends StatelessWidget {
  
    goBack(BuildContext context){
  
      Navigator.pop(context);
  
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(&quot;Second Screen&quot;),
        ),
  
        body: Center(
          child: RaisedButton(
            onPressed: () {
              goBack(context);
            },
            color: Colors.green,
            textColor: Colors.white,
            child: Text('Go Back To Previous Screen'),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>Here is the code for second activity which i want to navigate to:</p>
  <pre><code>class SecondActivity extends StatelessWidget {
  
    goBack(BuildContext context){
  
      Navigator.pop(context);
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(&quot;Second Screen&quot;),
        ),
  
        body: Center(
          child: RaisedButton(
            onPressed: () {
              goBack(context);
            },
            color: Colors.green,
            textColor: Colors.white,
            child: Text('Go Back To Previous Screen'),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>How does onclick function works on flutter and how do I implement this on my button</p>