flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[FIREBASE_AUTHENTICATION ] doesn't receive any OTP, error or warning

Open motorahul opened this issue 6 years ago β€’ 6 comments

i have tried firebase authentication for flutter web authenticaton using mobile number but didnot receive any Otp .and recieve any error or warning thanks

motorahul avatar Mar 18 '20 06:03 motorahul

i have tried firebase authentication for flutter web authenticaton using mobile number but didnot receive any Otp .and recieve any error or warning thanks

motorahul avatar Mar 18 '20 06:03 motorahul

Hi @motorahul can you please provide your flutter doctor -v , your flutter run --verbose, your pubspec.yaml and if possible a reproducible minimal code sample. Thank you

iapicca avatar Mar 20 '20 09:03 iapicca

flutter run --verbose

/Users/rahulrawat/.zprofile:export:1: not valid in this context: /Users/rahulrawat/sdkpath/flutter/bin”
rahulrawat@Rahuls-MacBook-Air pdt_pronewweb % flutter run --verbose
[  +34 ms] executing: [/Users/rahulrawat/sdkpath/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +63 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] fabeb2a16f1d008ab8230f450c49141d35669798
[        ] executing: [/Users/rahulrawat/sdkpath/flutter/] git describe --match v*.*.* --first-parent --long --tags
[  +27 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.14.6-0-gfabeb2a16
[  +13 ms] executing: [/Users/rahulrawat/sdkpath/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +19 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/beta
[        ] executing: [/Users/rahulrawat/sdkpath/flutter/] git ls-remote --get-url origin
[  +16 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +83 ms] executing: [/Users/rahulrawat/sdkpath/flutter/] git rev-parse --abbrev-ref HEAD
[  +19 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] beta
[  +13 ms] executing: sw_vers -productName
[  +33 ms] Exit code 0 from: sw_vers -productName
[        ] Mac OS X
[        ] executing: sw_vers -productVersion
[  +25 ms] Exit code 0 from: sw_vers -productVersion
[        ] 10.15.2
[        ] executing: sw_vers -buildVersion
[  +25 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 19C57
[  +53 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +6 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +61 ms] executing: /Users/rahulrawat/Library/Android/sdk/platform-tools/adb devices -l
[  +10 ms] Exit code 0 from: /Users/rahulrawat/Library/Android/sdk/platform-tools/adb devices -l
[        ] List of devices attached
[  +33 ms] executing: /Users/rahulrawat/sdkpath/flutter/bin/cache/artifacts/libimobiledevice/idevice_id -h
[  +85 ms] executing: /usr/bin/xcode-select --print-path
[  +14 ms] Exit code 0 from: /usr/bin/xcode-select --print-path
[        ] /Applications/Xcode.app/Contents/Developer
[   +1 ms] executing: /usr/bin/xcodebuild -version
[+1090 ms] Exit code 0 from: /usr/bin/xcodebuild -version
[   +3 ms] Xcode 11.3.1
           Build version 11C504
[   +4 ms] /usr/bin/xcrun simctl list --json devices
[ +193 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[   +4 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +77 ms] More than one device connected; please specify a device with the '-d <deviceId>' flag, or use '-d all' to act on all devices.
[ +402 ms] Chrome     β€’ chrome     β€’ web-javascript β€’ Google Chrome 80.0.3987.149
[   +1 ms] Web Server β€’ web-server β€’ web-javascript β€’ Flutter Tools
[  +23 ms] "flutter run" took 2,187ms.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:27:3)
#1      RunCommand.validateCommand (package:flutter_tools/src/commands/run.dart:325:7)
<asynchronous suspension>
#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:619:11)
<asynchronous suspension>
#3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:537:33)
<asynchronous suspension>
#4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:29)
#5      _rootRun (dart:async/zone.dart:1126:13)
#6      _CustomZone.run (dart:async/zone.dart:1023:19)
#7      _runZoned (dart:async/zone.dart:1518:10)
#8      runZoned (dart:async/zone.dart:1465:12)
#9      AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
#10     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:527:20)
#11     CommandRunner.runCommand (package:args/command_runner.dart:197:27)
#12     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:338:21)
<asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:29)
#14     _rootRun (dart:async/zone.dart:1126:13)
#15     _CustomZone.run (dart:async/zone.dart:1023:19)
#16     _runZoned (dart:async/zone.dart:1518:10)
#17     runZoned (dart:async/zone.dart:1465:12)
#18     AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
#19     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:288:19)
#20     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#21     new Future.sync (dart:async/future.dart:224:31)
#22     CommandRunner.run (package:args/command_runner.dart:112:14)
#23     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:231:18)
#24     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:22)
#25     _rootRun (dart:async/zone.dart:1126:13)
#26     _CustomZone.run (dart:async/zone.dart:1023:19)
#27     _runZoned (dart:async/zone.dart:1518:10)
#28     runZoned (dart:async/zone.dart:1502:12)
#29     run.<anonymous closure> (package:flutter_tools/runner.dart:62:18)
<asynchronous suspension>
#30     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:29)
#31     _rootRun (dart:async/zone.dart:1126:13)
#32     _CustomZone.run (dart:async/zone.dart:1023:19)
#33     _runZoned (dart:async/zone.dart:1518:10)
#34     runZoned (dart:async/zone.dart:1465:12)
#35     AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
#36     runInContext (package:flutter_tools/src/context_runner.dart:64:24)
#37     run (package:flutter_tools/runner.dart:51:10)
#38     main (package:flutter_tools/executable.dart:65:9)
#39     main (file:///Users/rahulrawat/sdkpath/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#40     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#41     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

motorahul avatar Mar 20 '20 14:03 motorahul

pubspec.yml

cupertino_icons: ^0.1.2
  firebase_auth: 0.15.5+2
  cloud_firestore: 0.13.0+1
  responsive: ^0.2.3+4
  carousel_pro:
  image_picker:
  google_sign_in:
  flare_flutter: ^2.0.1
  video_player:
  chewie: ^0.9.7
  audioplayers: ^0.14.0






dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - Assets/Images/

flutter doctor -v

rahulrawat@Rahuls-MacBook-Air pdt_pronewweb % flutter doctor -v 
[βœ“] Flutter (Channel beta, v1.14.6, on Mac OS X 10.15.2 19C57, locale en-GB)
    β€’ Flutter version 1.14.6 at /Users/rahulrawat/sdkpath/flutter
    β€’ Framework revision fabeb2a16f (7 weeks ago), 2020-01-28 07:56:51 -0800
    β€’ Engine revision c4229bfbba
    β€’ Dart version 2.8.0 (build 2.8.0-dev.5.0 fc3af737c7)

 
[βœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    β€’ Android SDK at /Users/rahulrawat/Library/Android/sdk
    β€’ Android NDK location not configured (optional; useful for native profiling support)
    β€’ Platform android-29, build-tools 29.0.2
    β€’ Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    β€’ Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    β€’ All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    β€’ Xcode at /Applications/Xcode.app/Contents/Developer
    β€’ Xcode 11.3.1, Build version 11C504
    βœ— CocoaPods installed but not working.
        You appear to have CocoaPods installed but it is not working.
        This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
        This can usually be fixed by re-installing CocoaPods. For more info, see https://github.com/flutter/flutter/issues/14293.
      To re-install CocoaPods, run:
        sudo gem install cocoapods

[βœ“] Chrome - develop for the web
    β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[βœ“] Android Studio (version 3.6)
    β€’ Android Studio at /Applications/Android Studio.app/Contents
    β€’ Flutter plugin version 44.0.2
    β€’ Dart plugin version 192.7761
    β€’ Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[βœ“] Connected device (2 available)
    β€’ Chrome     β€’ chrome     β€’ web-javascript β€’ Google Chrome 80.0.3987.149
    β€’ Web Server β€’ web-server β€’ web-javascript β€’ Flutter Tools

! Doctor found issues in 1 category.
rahulrawat@Rahuls-MacBook-Air pdt_pronewweb % 

motorahul avatar Mar 20 '20 14:03 motorahul

firebase authenticaton code

import 'dart:async';

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:pdtpronewweb/Screens/landingpage.dart';
import 'package:pdtpronewweb/Screens/responsive.dart';
import 'package:pdtpronewweb/Utils/colorUtils.dart';
import 'package:pdtpronewweb/Utils/customWidget.dart';
import 'package:pdtpronewweb/Utils/stringUtils.dart';
import 'package:pdtpronewweb/Utils/validationUtils.dart';
import 'package:pdtpronewweb/size_helpers/screenSize.dart';

class LoginPageWeb extends StatefulWidget {
  @override
  _LoginPageWebState createState() => _LoginPageWebState();
}

class _LoginPageWebState extends State<LoginPageWeb> {
  GlobalKey<FormState> _formKey = GlobalKey<FormState>();

  bool showOTPTextField = false;
  Timer _timer;
  int _start =30;
  String phoneNo;
  String smsCode;
  String verificationId;
  bool _validate = false;

  Future<void> verifyPhone() async {
    final PhoneCodeAutoRetrievalTimeout autoRetrieve =(String verId) {
      this.verificationId = verId;
    };
    final PhoneCodeSent smsCodeSent = (String verId, [int forceCodeResend]) {
      this.verificationId = verId;
      enableOtpTextField().then((value){
        print('Signed IN');
      })
      ;
    };
    final  PhoneVerificationCompleted verifiedSuccess = (AuthCredential user) {
      print('verified');
    };

    final PhoneVerificationFailed veriFailed = (AuthException exception) {
      print('${exception.message}');
    };

    await FirebaseAuth.instance.verifyPhoneNumber(
        phoneNumber: this.phoneNo,
        timeout: Duration(seconds: 5),
        verificationCompleted: verifiedSuccess,
        verificationFailed: veriFailed,
        codeSent: smsCodeSent,
        codeAutoRetrievalTimeout: autoRetrieve);
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    startTimer();

  }
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  void startTimer()
  {
    const timeSecond =Duration(seconds: 1);
    _timer =Timer.periodic(timeSecond, (Timer time) => setState(
            (){
          if(_start < 1){
            time.cancel();
          }else if(showOTPTextField==true){
            _start = _start - 1;
          }
        }
    ));
  }

  @override
  Widget build(BuildContext context) {
    return ResponsiveWidget(
      largeScreen: Scaffold(
        body: Center(
          child: Container(
              width: displayWidth(context) * 0.3,

              padding: EdgeInsets.only(top: 25.0,right: 50.0,left:50.0 ,bottom: 20.0),
              child:ListView(
                children: <Widget>[
                  Form(
                    key: _formKey,

                    child: Center(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Container(
                              height: 150,
                              child: Image.asset('Assets/Images/Logo.png',scale: 0.2,)),
                          SizedBox(
                            height: 15.0,
                          ),
                          CustomWidget.getText(StringUtils.verifyWithPhoneNumber,
                              style: TextStyle(color: Colors.orange[500]),
                              fontSize: 25,
                              fontWeight: FontWeight.bold),
                          SizedBox(
                            height: 10.0,
                          ),
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.stretch,
                            children: <Widget>[
                              TextFormField(
                                onChanged: (value) {
                                  this.phoneNo = value;
                                },
                                initialValue: "+91",
                                validator: ValidationUtils.validateMobile,
                                decoration: InputDecoration(
                                    hintText: '+91-9988776655',
                                    hintStyle: TextStyle(color: Colors.grey[300] , fontSize: 12.0),
                                    labelText: "Phone",
                                    labelStyle: TextStyle(color: Colors.grey[300],),
                                    enabledBorder: UnderlineInputBorder(
                                      borderSide: BorderSide(color: Colors.grey[400]),
                                    ),
                                    focusedBorder: UnderlineInputBorder(
                                      borderSide: BorderSide(color: Colors.grey[400]),
                                    )
                                ),
                                keyboardType: TextInputType.phone,
                              ),
                              showOTPTextField==false?disableOtpTextField():enableOtpTextField(),
                              SizedBox(height: 30.0,),
                              Container(
                                height: 50,
                                child: RaisedButton(
                                    onPressed: (){
                                      showOTPTextField==true?
                                      FirebaseAuth.instance.currentUser().then((user) {
                                        if(_formKey.currentState.validate()){
                                          if (user != null) {
                                            Navigator.pushReplacement(context, MaterialPageRoute(builder: (ctx)=>LandingPage()));
                                          } else {
                                            signIn();
                                          }
                                        }
                                      }):
                                      _validatorOTP();

                                      //otpVerificationDailog();
                                    },
                                    color: ColorUtils.buttonLightOrangeColor,
                                    child: showOTPTextField == false ?
                                    CustomWidget.getText(
                                      StringUtils.sendOtp,
                                      style: TextStyle(color: Colors.white),):
                                    CustomWidget.getText(
                                      StringUtils.verify,
                                      style: TextStyle(color: Colors.white),),

                                    shape: RoundedRectangleBorder(
                                      borderRadius: BorderRadius.circular(5.0),)
                                ),
                              ),
                            ],
                          ),
                          SizedBox(height: 30.0,),
                          Column(
                            children: <Widget>[
                              CustomWidget.getText(
                                  StringUtils.byContinuing,
                                  style: TextStyle(color: ColorUtils.frontLightGreyColor,fontSize: 13.0),
                                  textAlign: TextAlign.center
                              ),
                              RichText(
                                  text:
                                  TextSpan(
                                      children: [
                                        TextSpan(text: "I accept the  ",style: TextStyle(color: ColorUtils.frontLightGreyColor),),
                                        TextSpan(text: "terms and conditions" ,
                                          style: TextStyle(color: Colors.black54,fontSize: 13.0),
                                        )
                                      ]))
                            ],
                          ),
                          SizedBox(height: 30,),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              // Text('00:00 sec',style: TextStyle(color: Colors.grey)),
                              showOTPTextField == true? Text("00.$_start sec", style:TextStyle(color: Colors.grey)):
                              Text('00:00 sec',style: TextStyle(color: Colors.grey,fontSize: 13.0)),
                              GestureDetector(
                                onTap: (){},
                                child: Text('Re-send OTP',style: TextStyle(color: Colors.grey,fontSize: 13.0)),
                              ),
                            ],
                          ),
                          SizedBox(height: 30.0,),
                          CustomWidget.getRichText(
                              "Don't have an account? "," Sign-up",
                              textColor:ColorUtils.frontLightGreyColor,
                              newTextColor: ColorUtils.pinkColor
                          ),
                        ],
                      ),
                    ),
                  ),
                ],
              )

          ),
        ),

      ),
      smallScreen: Material(
        child: Container(
            padding: EdgeInsets.only(top: 25.0,right: 50.0,left:50.0 ,bottom: 20.0),
            child:ListView(
              children: <Widget>[
                Form(
                  key: _formKey,

                  child: Center(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Container(
                            height: 150,
                            child: Image.asset('Assets/Images/Logo.png',scale: 0.2,)),
                        SizedBox(
                          height: 15.0,
                        ),
                        CustomWidget.getText(StringUtils.verifyWithPhoneNumber,
                            style: TextStyle(color: Colors.orange[500]),
                            fontSize: 25,
                            fontWeight: FontWeight.bold),
                        SizedBox(
                          height: 10.0,
                        ),
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.stretch,
                          children: <Widget>[
                            TextFormField(
                              onChanged: (value) {
                                this.phoneNo = value;
                              },
                              initialValue: "+91",
                              validator: ValidationUtils.validateMobile,
                              decoration: InputDecoration(
                                  hintText: '+91-9988776655',
                                  hintStyle: TextStyle(color: Colors.grey[300] , fontSize: 12.0),
                                  labelText: "Phone",
                                  labelStyle: TextStyle(color: Colors.grey[300],),
                                  enabledBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color: Colors.grey[400]),
                                  ),
                                  focusedBorder: UnderlineInputBorder(
                                    borderSide: BorderSide(color: Colors.grey[400]),
                                  )
                              ),
                              keyboardType: TextInputType.phone,
                            ),
                            showOTPTextField==false?disableOtpTextField():enableOtpTextField(),
                            SizedBox(height: 30.0,),
                            Container(
                              height: 50,
                              child: RaisedButton(
                                  onPressed: (){
                                    showOTPTextField==true?
                                    FirebaseAuth.instance.currentUser().then((user) {
                                      if(_formKey.currentState.validate()){
                                        if (user != null) {
                                          Navigator.pushReplacement(context, MaterialPageRoute(builder: (ctx)=>LandingPage()));
                                        } else {
                                          signIn();
                                        }
                                      }
                                    }):
                                    _validatorOTP();

                                    //otpVerificationDailog();
                                  },
                                  color: ColorUtils.buttonLightOrangeColor,
                                  child: showOTPTextField == false ?
                                  CustomWidget.getText(
                                    StringUtils.sendOtp,
                                    style: TextStyle(color: Colors.white),):
                                  CustomWidget.getText(
                                    StringUtils.verify,
                                    style: TextStyle(color: Colors.white),),

                                  shape: RoundedRectangleBorder(
                                    borderRadius: BorderRadius.circular(5.0),)
                              ),
                            ),
                          ],
                        ),
                        SizedBox(height: 30.0,),
                        Column(
                          children: <Widget>[
                            CustomWidget.getText(
                                StringUtils.byContinuing,
                                style: TextStyle(color: ColorUtils.frontLightGreyColor,fontSize: 13.0),
                                textAlign: TextAlign.center
                            ),
                            RichText(
                                text:
                                TextSpan(
                                    children: [
                                      TextSpan(text: "I accept the  ",style: TextStyle(color: ColorUtils.frontLightGreyColor),),
                                      TextSpan(text: "terms and conditions" ,
                                        style: TextStyle(color: Colors.black54,fontSize: 13.0),
                                      )
                                    ]))
                          ],
                        ),
                        SizedBox(height: 30,),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: <Widget>[
                            // Text('00:00 sec',style: TextStyle(color: Colors.grey)),
                            showOTPTextField == true? Text("00.$_start sec", style:TextStyle(color: Colors.grey)):
                            Text('00:00 sec',style: TextStyle(color: Colors.grey,fontSize: 13.0)),
                            GestureDetector(
                              onTap: (){},
                              child: Text('Re-send OTP',style: TextStyle(color: Colors.grey,fontSize: 13.0)),
                            ),
                          ],
                        ),
                        SizedBox(height: 30.0,),
                        CustomWidget.getRichText(
                            "Don't have an account? "," Sign-up",
                            textColor:ColorUtils.frontLightGreyColor,
                            newTextColor: ColorUtils.pinkColor
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            )

        ),
      ),


    );
  }

  enableOtpTextField(){
    return TextFormField(
      onChanged: (value) {
        this.smsCode = value;
      },
      validator: ValidationUtils.validateOtp,

      decoration: InputDecoration(
        hintText: '.  .  .  .  .  .',
        hintStyle: TextStyle(color: ColorUtils.frontLightGreyColor , fontSize: 12.0),
        labelText: 'Enter OTP',
        labelStyle: TextStyle(color: ColorUtils.frontLightGreyColor,fontSize: 12.0
        ),

        enabledBorder: UnderlineInputBorder(
          borderSide: BorderSide(color: ColorUtils.frontLightGreyColor),
        ),

        focusedBorder:  UnderlineInputBorder(
          borderSide: BorderSide(color: ColorUtils.frontLightGreyColor),
        ),
      ),

      keyboardType: TextInputType.phone,
    );
  }

  disableOtpTextField(){
    return Container();
  }


  signIn(){
    final AuthCredential credential = PhoneAuthProvider.getCredential(verificationId: verificationId, smsCode: smsCode);
    FirebaseAuth.instance.signInWithCredential(credential).then((user) {
      Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (ctx)=>LandingPage()));
    }).catchError((e) {
      print(e);
    });
  }

  otpVerificationDailog(){
    return showDialog(
        context: context,
        builder: (BuildContext context){
          return SimpleDialog(
            contentPadding: EdgeInsets.only(
                left: 20.0 ,
                top: 20.0 ,
                right: 20.0 ,
                bottom: 40.0),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(10.0),
            ),
            title: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                CustomWidget.getText(StringUtils.otpVerification , style: TextStyle(
                  color: ColorUtils.buttonLightOrangeColor,fontSize: 15.0,
                )),
                GestureDetector(
                  onTap: (){
                    FirebaseAuth.instance.currentUser().then((user){
                      if (user !=null){
                        Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (ctx)=>LandingPage()));
                      }else{
                        verifyPhone();
                      }

                    });
                    setState(() {
                      showOTPTextField= true;
                    });
                    Navigator.pop(context);
                  },

                  child: Icon(Icons.close,color: ColorUtils.frontDarkGreyColor,size: 16.0,),
                )
              ],
            ),

            children: <Widget>[
              Column(
                children: <Widget>[
                  CustomWidget.getText(
                      StringUtils.anOtpHasBeenSentToYourMobileNumber,
                      style: TextStyle(
                          fontSize: 15.0 ,
                          color: ColorUtils.frontLightGreyColor
                      )
                  ),
                ],
              ),
            ],
          );
        }

    );
  }

  _validatorOTP() {
    if (_formKey.currentState.validate()) {
      otpVerificationDailog();
      // No any error in validation
    } else {
      // validation error
      setState(() {
        _validate = true;
      });
    }
  }
}

motorahul avatar Mar 20 '20 14:03 motorahul

Hey πŸ‘‹

Our rework of the firebase_auth plugin as part of the FlutterFire roadmap was published over a week ago with a ton of fixes and new features. Please could you try the new version and see if this is still an issue for you? If it is then please submit a new up to date GitHub issue.

For help migrating to the new plugins please see the new migration guide: https://firebase.flutter.dev/docs/migration

Salakar avatar Aug 25 '20 15:08 Salakar