title: Button OnPressed is not working in Flutter
body: <p>I have issue with the Raised button click. The method inside OnPressed() is not getting called. Ideally on the OnPressed() method i would like to have the pop up or a slider shown. I have created the example to show the problem currently faced. </p>
  
  <p>The main.dart file calls Screen2()</p>
  
  <pre><code>import 'package:flutter/material.dart';
  //import 'package:flutter_app/main1.dart';
  import 'screen2.dart';
  
  void main() =&gt; runApp(Lesson1());
  
  class Lesson1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
  return MaterialApp(
    home: Screen2(),
  );
  }
  }
  </code></pre>
  
  <p>and in Screen2()i have just have a RaisedButton and OnPressed() it needs to call the function ButtonPressed(). </p>
  
  <pre><code>import 'package:flutter/material.dart';
  class Screen2 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      backgroundColor: Colors.blue,
      title: Text('Screen 2'),
    ),
    body: Center(
      child: RaisedButton(
        color: Colors.blue,
        child: Text('Go Back To Screen 1'),
        onPressed: () {
          print('centrebutton');
          ButtonPressed();
        },
      ),
    ),
    );
   }
   }
  class ButtonPressed extends StatefulWidget {
  @override
  _ButtonPressedState createState() =&gt; _ButtonPressedState();
  
  }
  
  class _ButtonPressedState extends State&lt;ButtonPressed&gt; {
  @override
  Widget build(BuildContext context) {
  print ('inside button press');
  
  return Scaffold(
    appBar: AppBar(
      backgroundColor: Colors.red,
      title: Text('Screen 3'),
    ),
    // create a popup to show some msg. 
   );
   }
   }
  </code></pre>
  
  <p>On clicking the Raised button the print statement ('centerbutton') gets printed.<br>
  But the ButtonPressed() method is not getting called . 
  I am not able to see the print msg('inside button press') in the console. Pl. let me what could be the reason for ButtonPressed method not getting called. Attached the snapshot for your reference. </p>