title: How to hide a button on click in a flutter application?
body: <p><a href="https://i.stack.imgur.com/ffpmV.jpg" rel="nofollow noreferrer">normal image</a></p>
  
  <p><a href="https://i.stack.imgur.com/oczHl.jpg" rel="nofollow noreferrer">image after entering the mobile number</a></p>
  
  <p>See in this image when a user clicks on the login button the login button should disappear and a text field will be there followed by a submit button.</p>
  
  <p>I have the text field appearing on click of the login button, however I don't know how to disappear that login button once it is pressed.</p>
  
  <pre><code>import 'dart:async';
  import 'dart:ffi';
  import 'package:cloud_firestore/cloud_firestore.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
  import '../widgets/landing_page.dart';
  import '../screens/register.dart';
  import 'package:google_sign_in/google_sign_in.dart';
  import '../widgets/google_sign_in_btn.dart';
  import '../widgets/reactive_refresh_indicator.dart';
  
  // Each item on AuthStatus represents quite literally the status of the UI.
  // On SOCIAL_AUTH only the GoogleSignInButton will be visible.
  enum AuthStatus { SOCIAL_AUTH }
  
  class AuthScreen extends StatefulWidget {
    @override
    _AuthScreenState createState() =&gt; _AuthScreenState();
  }
  
  // On _AuthScreenState we start by defining the tag that will be used for our logger, then the default status as SOCIAL_AUTH, which means we need to do Google's sign in and the GoogleSignInButton will be visible and interactive.
  class _AuthScreenState extends State&lt;AuthScreen&gt; {
    String phoneNo;
    String smsCode;
    String verificationId;
    bool _smsCodeDisabled = true;
    bool isThere;
    bool isPresent;
    bool _canShowButton = false;
  
    final db = Firestore.instance;
   Firestore.instance.collection('transcriber_user_registeration').where('mobileno', isEqualTo: phoneNo)
    // .snapshots().listen(
    //       (data) { print("Inside phone number check : $data"); });
    //       // return phoneNumberCheck(phoneNo);
  
    // QuerySnapshot result =
    //       await Firestore.instance.collection('transcriber_user_registeration').getDocuments();
    //  var list = result.documents;
    // print("Before data loop");
    // list.forEach((data) =&gt; print(data));
    // print("After data loop");
  
    Future&lt;void&gt; phoneNumberCheck(String phoneNo) async {
      print("Start of the function");
      //bool registerState = false;
      //bool isPresent = false;
      Firestore.instance
          .collection("transcriber_user_registeration")
          .getDocuments()
          .then((QuerySnapshot snapshot) {
        snapshot.documents.forEach((f) async {
          if (isPresent = ('${f.data['mobileno']}' == phoneNo)) {
            print(isPresent);
            final PhoneCodeAutoRetrievalTimeout autoRetrieve = (String verId) {
              this.verificationId = verId;
            };
            final PhoneCodeSent smsCodeSent =
                (String verId, [int forceCodeResend]) {
              this.verificationId = verId;
              print("im in sms code dialog");
  //          smsCodeDialog(context).then((value) {
  //          print('Signed in');
  //          });
              setState(() {
                this._smsCodeDisabled = false;
              });
            };
            final PhoneVerificationCompleted verifySuccess =
                (AuthCredential user) {
              print("verified");
            };
  
            final PhoneVerificationFailed verifyFailed =
                (AuthException exception) {
              print('${exception.message}');
            };
  
            await FirebaseAuth.instance.verifyPhoneNumber(
              phoneNumber: this.phoneNo,
              codeAutoRetrievalTimeout: autoRetrieve,
              codeSent: smsCodeSent,
              timeout: const Duration(seconds: 5),
              verificationCompleted: verifySuccess,
              verificationFailed: verifyFailed,
            );
          }
  //        else {
  //          _showMessage();
  //        }
        });
      });
      //print("End of the function $isPresent");
    }
  
    Future&lt;void&gt; verifyPhone() async {
      // final PhoneCodeAutoRetrievalTimeout autoRetrieve = (String verId) {
      //   this.verificationId = verId;
      // };
      var tmp1 = phoneNo.toString();
      print('ref stsmt starts $tmp1');
      await phoneNumberCheck(phoneNo);
      print("After execution of the function $isPresent");
      print('bvnnn');
  
    }
  
    Future&lt;bool&gt; smsCodeDialog(BuildContext context) {
      return showDialog(
          context: context,
          barrierDismissible: false,
          builder: (BuildContext context) {
            return new AlertDialog(
              title: Text('Enter sms code'),
              content: TextField(onChanged: (value) {
                this.smsCode = value;
              }),
              contentPadding: EdgeInsets.all(10.0),
              actions: &lt;Widget&gt;[
                new FlatButton(
                    child: Text('Login'),
                    onPressed: () async {
                      //await signIn();
                      await FirebaseAuth.instance.currentUser().then((user) {
  //                      Navigator.push(
  //                          context,
  //                          MaterialPageRoute(
  //                              builder: (context) =&gt; LandingPageApp()));
                      });
                    })
              ],
            );
          });
    }
  
    signIn() {
      print("came to sign in page");
      final AuthCredential credential = PhoneAuthProvider.getCredential(
        verificationId: verificationId,
        smsCode: smsCode,
      );
  
      FirebaseAuth.instance.signInWithCredential(credential).then((user) {
        Navigator.push(
            context, MaterialPageRoute(builder: (context) =&gt; LandingPageApp()));
      }).catchError((e) {
        print(e);
      });
    }
  
    void hideWidget() {
      setState(() {
        _canShowButton != _canShowButton;
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          backgroundColor: Colors.white,
          body: Container(
            color: Colors.white,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.start,
              children: &lt;Widget&gt;[
                Flexible(
                  flex: 1,
                  child: new Container(
                    //color: Colors.white,
                    height: 200.0,
                    width: 400.0,
                    decoration: new BoxDecoration(
                      image: DecorationImage(
                        image: new AssetImage('assets/images/download.png'),
                      ),
                    ),
                  ),
                ),
                SizedBox(height: 20.0),
                Padding(
                  padding: EdgeInsets.symmetric(vertical: 16.0, horizontal: 20.0),
                  child: TextFormField(
                      decoration:
                      InputDecoration(hintText: 'Enter your Phone number'),
                      keyboardType: TextInputType.phone,
                      onChanged: (value) {
                        this.phoneNo = "+91$value";
                      },
                      validator: validateMobile),
                ),
                SizedBox(height: 10.0),
                Visibility(
                  visible: _canShowButton,
                  child: RaisedButton(
                    child: Text('Login'),
                    textColor: Colors.white,
                    elevation: 7.0,
                    color: Colors.blue,
                    onPressed: () async {
                      bool _canShowButton = true;
                      await verifyPhone();
                      setState(() {
                        _canShowButton = !_canShowButton;
                      });
                      hideWidget();
                      //_number();
                    },
                  ),
                ),
                _smsCodeDisabled
                    ? SizedBox(height: 10.0)
                    : Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: &lt;Widget&gt;[
                    Padding(
                      padding: EdgeInsets.symmetric(
                          horizontal: 20.0, vertical: 16.0),
                      child: TextFormField(
                          decoration:
                          InputDecoration(hintText: 'Enter OTP'),
                          keyboardType: TextInputType.number,
                          onChanged: (value) {
                            this.smsCode = value;
                          },
                          validator: validateOtp),
                    ),
                    SizedBox(height: 10.0),
                    RaisedButton(
                      onPressed: () async {
                        await signIn();
                        FirebaseAuth.instance.currentUser().then((user) {
                          print(["user", user]);
                          if (user != null) {
                            print(user.uid);
  //                                Navigator.of(context).pop();
  ////                                    Navigator.of(context).pushReplacementNamed('/homePage');
  //                                Navigator.of(context).push(
  //                                    MaterialPageRoute&lt;Null&gt;(
  //                                        builder: (BuildContext context) {
  //                                  return new LandingPageApp();
  //                                }));
                          } else {
                            print("user is null");
                            Navigator.of(context).pop();
                            signIn();
                          }
                        });
                      },
                      child: Text('Submit'),
                      textColor: Colors.white,
                      elevation: 7.0,
                      color: Colors.blue,
                    ),
                  ],
                ),
                SizedBox(
                  height: 20.0,
                ),
                Column(
                  children: &lt;Widget&gt;[
                    Row(children: &lt;Widget&gt;[
                      Padding(
                        padding: EdgeInsets.symmetric(
                            vertical: 16.0, horizontal: 20.0),
                        child: Text(
                          'Not a Registered User?',
                          style: TextStyle(
                            fontSize: 16,
                          ),
                        ),
                      ),
                      MaterialButton(
                        child: Text(
                          'Register',
                          style: TextStyle(
                            color: Colors.black,
                          ),
                        ),
                        //color: Colors.blue,
                        onPressed: () {
                          Navigator.push(
                              context,
                              MaterialPageRoute(
                                  builder: (context) =&gt; Register()));
                        },
                      ),
                    ]),
                  ],
                ),
              ],
            ),
          ));
    }
  }
  
  String validateMobile(String value) {
    //Indian Mobile numbers are of 10 digits only.
    if (value.length != 10)
      return 'Mobile number must be of 10 digits';
    else
      return null;
  }
  
  String validateOtp(String value) {
    //Otp needs to be of 6 digits
    if (value.length != 6)
      return 'OTP must be of 6 digits';
    else
      return null;
  }
  </code></pre>