title: How to call method from another class in Flutter(Dart)?
body: <p>I have created an Homepage and from that user can sign in for the app and in the next screen user can see their profile info(Only profile name) and under that their is signOut button. User can signOut from the app using signOut button.But it's not working for me.</p>
  
  <p>I want to call signOut method from main.dart by pressing signOut button in details.dart(both the classes are in different file)</p>
  
  <p>But when i press signOut Button in details.dart nothing happens!</p>
  
  <p>And code is given below:</p>
  
  <p>main.dart</p>
  
  <pre><code>import 'dart:async';
  
  import 'package:flutter/material.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:google_sign_in/google_sign_in.dart';
  import 'details.dart';
  
  void main() =&gt; runApp(new MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return new MaterialApp(
        theme: new ThemeData(
          primarySwatch: Colors.blue,
        ),
        debugShowCheckedModeBanner: false,
        home: new MyHomePage(),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    @override
    MyHomePageState createState() =&gt; MyHomePageState();
  }
  
  class MyHomePageState extends State&lt;MyHomePage&gt; {
    final FirebaseAuth firebaseAuth = FirebaseAuth.instance;
    final  GoogleSignIn googleSignIn = GoogleSignIn();
    static bool _LoginButton = true;
  
    void signOut(){
      googleSignIn.signOut();
      setState((){
        _LoginButton = true;
      });
      print(_LoginButton);
      print("User Signed Out");
    }
  
    Future&lt;FirebaseUser&gt; _signIn() async{
      if(_LoginButton==true){
        setState((){
          _LoginButton=false;
        });
        GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
        GoogleSignInAuthentication googleSignInAuthentication = await googleSignInAccount.authentication;
        FirebaseUser firebaseUser = await firebaseAuth.signInWithGoogle(idToken: googleSignInAuthentication.idToken, accessToken: googleSignInAuthentication.accessToken);
        print("Username is "+firebaseUser.displayName);
        setState((){
          _LoginButton = true;
        });
        Navigator.push(context, MaterialPageRoute(builder: (context) =&gt; details(firebaseUser.displayName,signOut)));
  
        return firebaseUser;
      }
    }
  
    bool _LoginButtonBool(){
      return _LoginButton;
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(title: Text("Google auth with firebase"),),
        body: Center(
          child: _LoginButtonBool()?Container(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: &lt;Widget&gt;[
                MaterialButton(onPressed: _LoginButtonBool() ? () =&gt; _signIn().then((FirebaseUser firebaseuser ) =&gt;print(firebaseuser)).catchError((e) =&gt; print(e)): null,
                child: Text("Login"),color: Colors.orange,),
              ],
            ),
          ):CircularProgressIndicator(backgroundColor: Colors.greenAccent.withOpacity(0.01),),
        ),
      );
    }
  }
  </code></pre>
  
  <p>details.dart</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutter_auth/main.dart';
  
  class details extends StatelessWidget {
    String name;
    final Function callback;
    details(this.name,this.callback);
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body:Center(child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: &lt;Widget&gt;[
            Text(name),
            MaterialButton(onPressed: () =&gt; callback,
            child: Text("Log out"),color: Colors.orange),
          ],
        ),),
      );
    }
  }
  </code></pre>