FirebaseAuth phone authentication error, error code 17499 - firebase

I started getting below error with Firebase Phone Authentication in my flutter app. What does error code 17499 mean? I couldn't get any info on this. Any hints to fix this? Thanks
E/FirebaseAuth(20851): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 Requests from this Android client application xx.xxxxx.xxxxxxx are blocked.
E/flutter (20851): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'String'
E/flutter (20851): #0 MethodChannelFirebaseAuth.verifyPhoneNumber.<anonymous closure>
#action
Future<void> getCodeWithPhoneNumber(
BuildContext context, String phoneNumber) async {
isLoginLoading = true;
await _auth.verifyPhoneNumber(
phoneNumber: phoneNumber,
timeout: const Duration(seconds: 60),
verificationCompleted: (AuthCredential auth) async {
await _auth.signInWithCredential(auth).then((UserCredential value) {
if (value != null && value.user != null) {
print('Authentication successful');
onAuthenticationSuccessful(context, value);
} else {
loginScaffoldKey.currentState!.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
'Invalid code/invalid authentication',
style: TextStyle(color: Colors.white),
),
));
}
}).catchError((error) {
print(error.toString());
loginScaffoldKey.currentState!.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
'Something has gone wrong, please try later',
style: TextStyle(color: Colors.white),
),
));
});
},
verificationFailed: (FirebaseAuthException authException) {
if(authException != null && authException.message != null){
print('Error message: ' + authException.message!);
loginScaffoldKey.currentState!.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
authException.message!,
style: TextStyle(color: Colors.white),
), //Please enter your number in E.164 format.
));
isLoginLoading = false;
//Text(authException.message+' The phone number format is incorrect. [+][country code][number]'
}
},
codeSent: (String verificationId, [int? forceResendingToken]) async {
actualCode = verificationId;
isLoginLoading = false;
await Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => const OtpPage()));
},
codeAutoRetrievalTimeout: (String verificationId) {
actualCode = verificationId;
});
}

This worked from after migrating to Dart only FlutterFire initialisation method.
It stopped working with manual initialisation using google-services.json.

Related

When the user trying to login, it doesn't stores their data in firestore, When I click Confirm location button it showing following error

class AuthProvider with ChangeNotifier {
FirebaseAuth _auth = FirebaseAuth.instance;
String smsOtp;
String verificationId;
String error ='';
UserServices _userServices = UserServices();
bool loading = false;
LocationProvider locationData = LocationProvider();
String screen;
double latitude;
double longitude;
String address;
Future<void> verifyPhone({BuildContext context, String number}) async {
this.loading=true;
notifyListeners();
final PhoneVerificationCompleted verificationCompleted =
(PhoneAuthCredential credential) async {
this.loading=false;
notifyListeners();
await _auth.signInWithCredential(credential);
};
final PhoneVerificationFailed verificationFailed =
(FirebaseAuthException e) {
this.loading=false;
print(e.code);
this.error=e.toString();
notifyListeners();
};
final PhoneCodeSent smsOtpSend = (String verId, int resendToken) async {
this.verificationId = verId;
};
//open dialog to enter received OTP sms
smsOtpDialog(context, number);
try {
_auth.verifyPhoneNumber(
phoneNumber: number,
verificationCompleted: verificationCompleted,
verificationFailed: verificationFailed,
codeSent: smsOtpSend,
codeAutoRetrievalTimeout: (String verId){
this.verificationId = verId;
},
);
} catch (e) {
this.error=e.toString();
this.loading=false;
notifyListeners();
print(e);
}
}
Future<bool> smsOtpDialog(BuildContext context, String number) {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Column(
children: [
Text('Verification Code'),
SizedBox(height: 6,),
Text('Enter 6 digits OTP received via SMS',
style: TextStyle(color: Colors.grey,fontSize: 12),
),
],
),
content: Container(
height: 85,
child: TextField(
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
maxLength: 6,
onChanged: (value){
this.smsOtp = value;
},
),
),
actions: [
FlatButton(
onPressed: ()async{
try{
PhoneAuthCredential phoneAuthCredential =
PhoneAuthProvider.credential(
verificationId: verificationId, smsCode: smsOtp);
final User user = (await _auth.signInWithCredential(phoneAuthCredential)).user;
if(user!=null){
this.loading=false;
notifyListeners();
_userServices.getUserById(user.uid).then((snapShot){
if(snapShot.exists){
//user data already exists
if(this.screen=='Login'){
//need to check user data already exists in database or not
//if its login,no new data, so no need to update
Navigator.pushReplacementNamed(context, HomeScreen.id);
}else{
//need to update new selected address
print('${locationData.latitude} : ${locationData.longitude}');
updateUser(id: user.uid, number: user.phoneNumber);
Navigator.pushReplacementNamed(context, HomeScreen.id);
}
}else{
//user data doesn't exists
//will create new data in db
_createUser(id: user.uid, number: user.phoneNumber);
Navigator.pushReplacementNamed(context, HomeScreen.id);
}
});
}else
{
print('Login Failed');
}
} catch(e){
this.error = 'Invalid OTP';
notifyListeners();
print(e.toString());
Navigator.of(context).pop();
}
},
child: Text('SUBMIT',style: TextStyle(color: Theme.of(context).primaryColor),),
),
],
);
}).whenComplete(() {
this.loading=false;
notifyListeners();
});
}
void _createUser({String id, String number} ) {
_userServices.createUserData({
'id':id,
'number':number,
'latitude':this.latitude,
'longitude':this.longitude,
'address':this.address
});
this.loading=false;
notifyListeners();
}
Future <bool> updateUser({String id, String number,} ) async{
try{
_userServices.updateUserData({
'id':id,
'number':number,
'latitude':this.latitude,
'longitude':this.longitude,
'address':this.address
});
this.loading=false;
notifyListeners();
return true;
}catch(e){
print('Error $e');
return false;
}
}
}
======== Exception caught by gesture ===============================================================
The following NoSuchMethodError was thrown while handling a gesture:
The getter 'uid' was called on null.
Receiver: null
Tried calling: uid
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 _MapScreenState.build. (package:flutter_hasho_user/screens/map_screen.dart:146:44)
#2 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
#3 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1111:38)
#4 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
...
Handler: "onTap"
Recognizer: TapGestureRecognizer#3d7f8
debugOwner: GestureDetector
state: possible
won arena
finalPosition: Offset(184.2, 647.6)
finalLocalPosition: Offset(164.2, 15.6)
button: 1
sent tap down
====================================================================================================
I am pretty sure your issue is calling .uid on a user in your else block when the user is null, which throws an error. You should make sure that the user class is initialized or something similar atleast.
else{
_createUser(id: user.uid, number: user.phoneNumber); // [user] is null
Navigator.pushReplacementNamed(context, HomeScreen.id);
}

flutter phone auth doens't work in my boss phone

helllo
I'm trying to make phone auth with flutter
I managed to implement but doens't work in my boss phone (android)
in my phone it works.
that's why I'm almost crazy
I wanna connect boss phone with cable debug mode
but my boss refused to it. 😫😫😫
here's my code
Future createUserWithPhone({String phoneNumber, BuildContext context}) async {
String phoneNumberWith82 = '+82 $phoneNumber';
await fAuth.verifyPhoneNumber(
phoneNumber: phoneNumberWith82,
timeout: Duration(seconds: 60),
verificationCompleted: (AuthCredential authCredential) async {
print('here verificationcompleted');
✅ not a big deal, verificationCompleted doesn't work don't know why
await fAuth
.signInWithCredential(authCredential)
.then((AuthResult result) {
Fluttertoast.showToast(
msg: "success",
backgroundColor: Colors.black26,
textColor: Colors.white,
);
}).catchError((e) {
print('Error Occurs ⭐3');
return "error";
});
},
verificationFailed: (AuthException exception) {
Fluttertoast.showToast(
msg: 'too many request',
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0);
return "error";
},
codeSent: (String verificationId, [int forceResendingToken]) async {
final _codeController = TextEditingController();
await showDialog(
context: context,
barrierDismissible: false,
builder: (context) => AlertDialog(
title: Text("write auth 6digit"),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
TextField(
controller: _codeController,
keyboardType: TextInputType.number,
),
],
),
actions: <Widget>[
FlatButton(
child: Text("verify"),
textColor: Constants.kPrimaryOrange,
// color: Constants.kPrimaryOrange,
onPressed: () async {
var _credential = PhoneAuthProvider.getCredential(
verificationId: verificationId,
smsCode: _codeController.text.trim());
✅ Error Occurs HERE ✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅
await fAuth
.signInWithCredential(_credential)
.then((AuthResult result) async {
var snapshot = await Firestore.instance
.collection('users')
.where('pid', isEqualTo: result.user.phoneNumber)
.getDocuments();
/// id doesn't exist.
if (snapshot.documents.length == 0) {
await Firestore.instance
.collection('users')
.document(result.user.uid)
.setData({
'uid': result.user.uid,
'pid': result.user.phoneNumber,
'name': randomName,
'createdAt': DateTime.now(),
'storeName': '',
});
Fluttertoast.showToast(
msg: "33",
backgroundColor: Colors.black26,
textColor: Colors.white,
);
} else {
Fluttertoast.showToast(
msg: " id exists",
backgroundColor: Colors.black26,
textColor: Colors.white,
);
}
setUser(result.user);
Navigator.pushNamedAndRemoveUntil(
context, SplashScreen.id, (route) => false,
arguments: result.user);
✅ catch }).catchError((e) {
Fluttertoast.showToast(
msg: e.toString(),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ErrorReading(errorMsg: e.toString())),
);
// Navigator.pop(context);
return "error";
});
},
),
FlatButton(
child: Text("close"),
textColor: Constants.kPrimaryOrange,
// color: Constants.kPrimaryOrange,
onPressed: () {
print('Error Occurs ⭐');
Navigator.pop(context);
},
)
],
),
);
},
codeAutoRetrievalTimeout: (String verificationId) {
verificationId = verificationId;
});
I don't know cause of this problem , so i cannot fix it.
I used to toast to find error point.
then i found it ✅ look at this emoji
anybody?
firebase_auth: ^0.16.1
firebase_core: ^0.4.0
cloud_firestore: ^0.13.0
firebase_storage: ^3.1.6
I tryed firebase_auth ^18 with core ^5 but many place to change recent code so I trying to figuring out with these versions
Follow the steps as mentioned here.
You need to add both the SHA-1 Fingerprint and enable the Device Check API for Phone Auth to work in Android.
If you need a code sample for Phone Auth to work in
firebase_auth ^18 with core ^5, do let me know will edit this answer.

FirabaseAuth can't catch exception in Flutter

I'm working on a signup screen for my app. I implemented firebase and can authenticate user and save some user info into firebase database succesfully. I started to check if userName field is empty or not. But firebase sometimes can not catch exception about bad formatted email address. It works for password (min 6 char) everytime but sometimes work for email. I can't find any solution. Here is my code. Is there anybody who have an idea?
onPressed: () async {
if (validateName(userName) && validateEmail(email)) {
setState(() {
showSpinner = true;
});
try {
final newUser =
await _auth.createUserWithEmailAndPassword(
email: email, password: password);
if (newUser != null) {
//get name and update user profile
UserUpdateInfo userUpdateInfo = UserUpdateInfo();
userUpdateInfo.displayName = userName;
FirebaseUser user = await _auth.currentUser();
await user.updateProfile(userUpdateInfo);
await user.reload();
Navigator.pushNamed(context, NavigationScreen.id);
}
setState(() {
showSpinner = false;
});
} on PlatformException catch (e) {
setState(() {
showSpinner = false;
});
Fluttertoast.showToast(
msg: e.message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 3,
backgroundColor: Colors.white,
textColor: Colors.red,
fontSize: 18.0,
);
}
} else {
Fluttertoast.showToast(
msg: 'You must ente all information',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 3,
backgroundColor: Colors.white,
textColor: Colors.red,
fontSize: 18.0,
);
}
},
//name TextField validation
bool validateName(String name) {
if (name != null && name.length > 2) {
return true;
} else {
return false;
}
}
//email TextField validation
bool validateEmail(String email) {
if (email != null) {
return true;
} else {
return false;
}
}
createUserWithEmailAndPassword returns a Future<AuthResult>, to catch the error you can do the following:
final newUser = await _auth.createUserWithEmailAndPassword(email: email, password: password).catchError((err) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text("Error"),
content: Text(err.message),
actions: [
FlatButton(
child: Text("Ok"),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
Using catchError, it will handles errors emitted by this Future, and then showDialog will display a dialog with the error.

How to make register using email/password and send Code to the phone in Firebase

I want to allow users to register an account on my app using flutter with email/password, and then send code to the phone. So when user enters their data to Sign up, it should register them with their email and then use their phone to the verity code. Also the user can't complete the registration and go to the Home page Without checking the entered code.
But in my code it's not working what i want do it.
My click function:
dynamic ruselt= await _auth.regsiterwithemail(_emailcontroller.text,_passwordcontroller.text);
if (ruselt!=null){
setState(() async {
loading =false;
verfitycode().verfityphoen(context);
});
}else{
setState(() {
loading=false;
SweetAlert.show(context,
title: "Title",
style: SweetAlertStyle.confirm,
subtitle: "Subtitle");
});
}
My registration function:
Future regsiterwithemail(String email , String password )
async {
try{
AuthResult result =await _auth.createUserWithEmailAndPassword(email: email, password: password);
FirebaseUser user =result.user;
print('oky');
return _userfirebaseUser(user);
}catch(e){
print(e.toString());
return null;
}
}
class for verity code
class verfitycode {
String phonenumber;
String smsCode;
String vialdid;
GlobalKey<FormState>_form;
Future<void> verfityphoen(BuildContext context)async{
final PhoneCodeAutoRetrievalTimeout AutoRetriv =(String verid) {
this.vialdid =verid;
};
final PhoneCodeSent smsCodeset =(String verid,[int forceResendingToken]){
this.vialdid=verid;
smscodeDialog(context);
};
final PhoneVerificationCompleted verfiedcompletd=(AuthCredential user){
print('verfild');
};
final PhoneVerificationFailed verfilederror =(AuthException exception){
print('${exception.message}');
};
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber:"+967776523152",
timeout: const Duration(seconds:5),
verificationCompleted: verfiedcompletd,
verificationFailed: verfilederror,
codeSent: smsCodeset,
codeAutoRetrievalTimeout: AutoRetriv
);
}
Future<bool> smscodeDialog(BuildContext context){
Alert(
context: context,
title: "رمز التحقق",
content: Column(
children: <Widget>[
Form(
key: _form,
child: Directionality(
textDirection: TextDirection.rtl,
child:
TextField(
onChanged: (val){
this.smsCode=val;
},
decoration:InputDecoration (
icon: Icon(Icons.supervisor_account),
labelText: 'ادخل رمز التحقق',
),
),
)
)
],
),
buttons: [
DialogButton(
child: Text('خروج', style: TextStyle(color: Colors.white, fontSize:18)), onPressed:()=>Navigator.pop(context)),
DialogButton(
onPressed: (){
// _form.currentState.validate();
FirebaseAuth.instance.currentUser().then((user) {
if (user != null) {
Navigator.pop(context);
Navigator.push(context,
MaterialPageRoute(builder: (context) => Home()));
} else {
Navigator.pop(context);
_testSignlink();
}
});
},
child: Text(
"ادخل الرمز",
style: TextStyle(color: Colors.white, fontSize:18),
),
),
]).show();
}
_testSignlink() async {
FirebaseUser user;
String _smsCodeController;
final AuthCredential credential = PhoneAuthProvider.getCredential(
verificationId: vialdid,
smsCode: smsCode,
);
await user.linkWithCredential(credential).then((user){
print(user.user.uid);
}).catchError((onError){
print(onError.toString());
});
_smsCodeController = '';
return 'signInWithPhoneNumber succeeded: $user';
}
}

Flutter Firebase Auth: A network error (such as timeout, interrupted connection or unreachable host) has occurred

I am trying to integrate authentication on Flutter using firebase_auth.
However, whenever I call the verifyPhoneNumber("+256XXXXXXXXXX") I get the error message A network error (such as timeout, interrupted connection or unreachable host) has occurred., that is from the PhoneVerificationFailed callback. An for that reason cannot get the SMS.
I have tried;
Adding network permissions as seen below to my file (my internet connection works, as I am able to Google via the emulator)
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
Checking the validity of my API keys
I am totally confused as to why Flutter is unable to communicate with firebase. I have two questions.
How can I eliminate this error?
What other cases might cause this error besides a lacking internet connection?
My implimentatioin is as below;
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';
}
}
In my case I solved allowing Outgoing Connections on the Xcode's Runner.xcworkspace
In my case, my VPN was causing the problem. Disabling the VPN and testing it again solved the error. I hope it helps.
if you are trying this out in a simulator, then this error may pop up as the internet of your simulator is not connected. To solve this you can run your app on a physical device and it will work!
I am late to the party but I found another solution.
If using an android emulator, disabling the Android Studio HTTP proxy settings can restore the network connection.
Normally when the emulator is doing a lot of work on the thread, it tends to misbehave, such a losing internet connectivity even if your PC is well connected.
My suggestion(Which worked for me) is you kill the emulator, and go to Android Studio AVD Manager and Wipe Data for that Emulator, then restart the Emulator, it worked for me.
Kindly find below the image screenshot
"I am late to the party but I found another solution.
If using an android emulator, disabling the Android Studio HTTP proxy settings can restore the network connection." - MaximeBeasse
This network error has stopped me too and I have been seeking an answer ... After reading MaximeBeasse's response above and trying it out, I found that it worked : ) Authentication now works! Finally I can move on!
Many thanks #MaximeBeasse -- salute his answer please
Open Terminal in the project folder, run the following two commands:
adb kill-server
adb start-server
If adb is not recognized, add C:\Users\USERNAME\AppData\Local\Android\Sdk\platform-tools to environement variables.
import 'package:badam/varify.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'dart:async';
import 'HomePage.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'FireBase Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: new LoginPage(),
routes: <String, WidgetBuilder>{
'/loginpage' : (BuildContext context) => Dash(),
'/landpage' : (BuildContext context) => LoginPage(),
}
);
}
}
class LoginPage extends StatefulWidget {
#override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
String phoneNo, smsId, verificationId;
Future<void> verifyPhone() async{
final PhoneCodeAutoRetrievalTimeout autoRetrieve = (String verId){
this.verificationId = verId;
};
final PhoneCodeSent smsCodeSent = (String verId, [int forceCodeResend]){
this.verificationId = verId;
smsCodeDialoge(context).then((value){
print('Signed In');
});
};
final PhoneVerificationCompleted verifiedSuccess = (AuthCredential auth){
print('verified');
};
final PhoneVerificationFailed verifyFailed = (AuthException e) {
print('${e.message}');
};
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: phoneNo,
timeout: const Duration(seconds: 5),
verificationCompleted: verifiedSuccess,
verificationFailed: verifyFailed,
codeSent: smsCodeSent,
codeAutoRetrievalTimeout: autoRetrieve,
);
}
Future<bool> smsCodeDialoge(BuildContext context){
return showDialog(context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return new AlertDialog(
title: Text('Enter OTP'),
content: TextField(
onChanged: (value) {
this.smsId = value;
},
),
contentPadding: EdgeInsets.all(10.0),
actions: <Widget>[
new FlatButton(
onPressed: (){
FirebaseAuth.instance.currentUser().then((user){
if(user != null){
Navigator.of(context).pop();
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Dash()),
);
}
else{
Navigator.of(context).pop();
signIn(smsId);
}
}
);
},
child: Text('Done', style: TextStyle( color: Colors.blue),))
],
);
},
);
}
Future<void> signIn(String smsCode) async {
final AuthCredential credential = PhoneAuthProvider.getCredential(
verificationId: verificationId,
smsCode: smsCode,
);
await FirebaseAuth.instance.signInWithCredential(credential)
.then((user){
Navigator.of(context).pushReplacementNamed('/loginpage');
}).catchError((e){
print(e);
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Sign In')
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Phone Auth',style: TextStyle(fontSize: 20,color: Colors.blue),),
Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
decoration: InputDecoration(
hintText: 'Enter your phone number',
),
onChanged: (value){
this.phoneNo = value;
},
),
),
SizedBox(height: 10.0),
RaisedButton(
onPressed: verifyPhone,
child: Text('Verify', style: TextStyle(color: Colors.white),),
elevation: 7.0,
color: Colors.blue,
)
],
),
);
}
}
It worked for me, hope this helps you!

Resources