title: Flutter bloc and Firebase phone auth
body: <p><code>enter code here</code>I'm trying to create a LoginBloc which uses Firebase phone authentication. I created a StreamController for phoneNumber, smsCode and for verificationId. I'd like to add their values in VerificationNumber() method dynamically with the help of Bloc pattern. This is the LoginBloc within the verificationNumber():</p>
  
  <pre><code>class LoginBloc extends Object with AuthValidator implements BlocBase {
  
    String _phone;
    String _sms;
    String _verifId;
  
    StreamController&lt;String&gt; _phoneController=StreamController&lt;String&gt;.broadcast();
  
    //Sink&lt;String&gt; get _addPhone=&gt;_phoneController.sink;
    Stream&lt;String&gt; get getPhone=&gt;_phoneController.stream.transform(validatePhone);
  
    StreamController&lt;String&gt; _codeController=StreamController&lt;String&gt;.broadcast();
  
    Stream&lt;bool&gt; get registerValid =&gt; Observable.combineLatest2(getPhone,getPhone
            ,(e, p) =&gt;true);
  
    //Sink&lt;String&gt; get _addCode=&gt;_phoneController.sink;
    Stream&lt;String&gt; get getCode=&gt;_phoneController.stream.transform(validatePhone);
    Function(String) get onPhoneChanged =&gt; _phoneController.sink.add;
  
    StreamController&lt;String&gt; _verificationIdController=StreamController&lt;String&gt;.broadcast();
  
    Sink&lt;String&gt; get _addVerification=&gt;_verificationIdController.sink;
    Stream&lt;String&gt; get getVerification=&gt;_verificationIdController.stream;
  
    @override
    void dispose() {
      _phoneController.close();
      _codeController.close();
      _verificationIdController.close();
    }
  
    Future&lt;void&gt; verifyPhone(String phone, String verifId,String sms) async {
  
      _phone=phone;
      _sms=sms;
      _verifId=verifId;
  
      final PhoneCodeAutoRetrievalTimeout autoRetrieve=(String verId) {
        _verifId=verId;
        _addVerification.add(_verifId);
      };
  
      final PhoneCodeSent smsCodeSent=(String verId,[int forceCodeRetrieve]) {
        _verifId=verId;
        _addVerification.add(_verifId);
      };
  
      final PhoneVerificationCompleted phoneVerificationCompleted=(FirebaseUser user) {
        print("User $user");
      };
  
      final PhoneVerificationFailed phoneVerificationFailed=(AuthException exception) {
        print("Error $exception");
      };
  
      await FirebaseAuth.instance.verifyPhoneNumber(
          phoneNumber: _phone,
          timeout: Duration(minutes: 1),
          verificationCompleted: phoneVerificationCompleted,
          verificationFailed: phoneVerificationFailed,
          codeSent: smsCodeSent,
          codeAutoRetrievalTimeout: autoRetrieve);
    }
  }
  
  LoginBloc loginBloc=LoginBloc();
  </code></pre>