title: Flutter Firebase Auth: A network error (such as timeout, interrupted connection or unreachable host) has occurred
body: <p>I am trying to integrate authentication on Flutter using <code>firebase_auth</code>.</p>
  <p>However, whenever I call the <code>verifyPhoneNumber(&quot;+256XXXXXXXXXX&quot;)</code> I get the error message <code>A network error (such as timeout, interrupted connection or unreachable host) has occurred.</code>, that is from the <code>PhoneVerificationFailed</code> callback. An for that reason cannot get the SMS.</p>
  <p>I have tried;</p>
  <ol>
  <li><p>Adding network permissions as seen below to my file (my internet  connection works, as I am able to Google via the emulator)</p>
  <p><code>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt; &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot;/&gt; &lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot;/&gt;</code></p>
  </li>
  <li><p>Checking the validity of my API keys</p>
  </li>
  </ol>
  <p>I am totally confused as to why Flutter is unable to communicate with firebase. I have two questions.</p>
  <ol>
  <li>How can I eliminate this error?</li>
  <li>What other cases might cause this error besides a lacking internet connection?</li>
  </ol>
  <p>My implimentatioin is as below;</p>
  <pre><code>import 'package:firebase_auth/firebase_auth.dart';
  
  FirebaseAuth auth = FirebaseAuth.instance;
  
  var message;
  // fire this when Phone verification is completed
   final PhoneVerificationCompleted verificationCompleted =
        (AuthCredential phoneAuthCredential) {
      auth.signInWithCredential(phoneAuthCredential);
  
      message = 'Received phone auth credential: $phoneAuthCredential';
      print(message);
    };
  
  // fire this when Phone verification fails
    final PhoneVerificationFailed verificationFailed =
        (AuthException authException) {
      message =
          'Phone verification failed. Code: ${authException.code}. Message: ${authException.message}';
      print(message);
    };
  
    // fire this when SMS code is sent is sent.
    final PhoneCodeSent codeSent =
        (String verificationId, [int forceResendingToken]) async {
      verificationId = verificationId;
      print('Sent verification code');
    };
  
  
    // fire this when smsCode expires
    final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =
        (String verificationId) {
      verificationId = verificationId;
      print('Auto retrival time-out');
    };
  
  // verify phone number
  verifyPhoneNumber(String phoneNumber) {
    auth.verifyPhoneNumber(
        phoneNumber: phoneNumber,
        timeout: const Duration(seconds: 30),
        verificationCompleted: verificationCompleted,
        verificationFailed: verificationFailed,
        codeSent: codeSent,
        codeAutoRetrievalTimeout: codeAutoRetrievalTimeout);
        print('Verification Initiated');
  }
  
  // sign in with phone.
  signInWithPhoneNumber(String smsCode, String verificationId) async {
    final AuthCredential credential = PhoneAuthProvider.getCredential(
      verificationId: verificationId,
      smsCode: smsCode,
    );
  
    final FirebaseUser user = (await auth.signInWithCredential(credential)).user;
    final FirebaseUser currentUser = await auth.currentUser();
  
    assert(user.uid == currentUser.uid);
  
    if (user != null) {
      message = 'Successfully signed in, uid: ' + user.uid;
    } else {
      message = 'Sign in failed';
    }
  }
  </code></pre>