Unable to access server. #86
Replies: 1 comment 1 reply
-
Hi, Can you please post the complete server logs ? That will be helpful |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When i try to access the plugin it shows
I/flutter (31471): --- Package Error ---
I/flutter (31471): Unable to access server. 😑
I/flutter (31471): --- End Package Error ---
I/flutter (31471): Could not send OTP to [email protected]
Sorry for the delayed response
I have updated log and error
" log "
I/flutter (10760): email-auth >> Initialising Email-Auth server
I/flutter (10760): email-auth >> Remote server is not available -- using test server --
I/flutter (10760): email-auth >> ❗ Warning this is not reliable on production
2
D/InputMethodManager(10760): showSoftInput() view=io.flutter.embedding.android.FlutterView{b6386ea VFE...... .F...... 0,0-1080,2280 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
I/flutter (10760): --- Package Error ---
I/flutter (10760): Invalid argument(s): No host specified in URI sandbox.smtp.mailtrap.io/test/dart
I/flutter (10760): --- End Package Error ---
I/flutter (10760): --- package Error ---
I/flutter (10760): email-auth >> The remote server is not a valid.
I/flutter (10760): email-auth >> configured server : "sandbox.smtp.mailtrap.io"
I/flutter (10760): --- package Error ---
2
D/InsetsController(10760): show(ime(), fromIme=true)
D/EGL_emulation(10760): app_time_stats: avg=286.52ms min=172.47ms max=480.91ms count=4
D/EGL_emulation(10760): app_time_stats: avg=173.06ms min=11.61ms max=504.29ms count=8
I/flutter (10760): --- Package Error ---
I/flutter (10760): Unable to access server. 😑
I/flutter (10760): --- End Package Error ---
I/flutter (10760): Could not send OTP to [email protected]
" code "
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:email_auth/email_auth.dart';
import 'package:instagram/core/utility/constant.dart';
import '../../../../core/resources/color_manager.dart';
import '../../../../core/resources/styles_manager.dart';
import '../../../widgets/global/custom_widgets/custom_elevated_button.dart';
import 'name_password.dart';
//emailAuth.config(remoteServerConfiguration); add your server config to run send email verification code
class VerificationScreen extends StatefulWidget {
final String email;
final TextEditingController emailcontroller;
const VerificationScreen(
{Key? key, required this.email, required this.emailcontroller})
: super(key: key);
@OverRide
// ignore: library_private_types_in_public_api
_VerificationScreenState createState() => _VerificationScreenState();
}
class _VerificationScreenState extends State {
final _formKey = GlobalKey();
final TextEditingController _otpController =
TextEditingController(text: '85321');
bool _isButtonDisabled = true;
int _remainingTime = 20;
bool _resendButtonDisabled = true;
final EmailAuth _emailAuth = EmailAuth(sessionName: "Sample session");
@OverRide
void initState() {
super.initState();
_sendOTP();
_startTimer();
email();
}
void _startTimer() {
const oneSec = Duration(seconds: 1);
Timer.periodic(oneSec, (timer) {
setState(() {
if (_remainingTime < 1) {
_resendButtonDisabled = false;
timer.cancel();
} else {
_remainingTime -= 1;
}
});
});
}
void _sendOTP() async {
var res =
await _emailAuth.sendOtp(recipientMail: widget.email, otpLength: 6);
if (res) {
print("OTP sent to ${widget.email}");
} else {
print("Could not send OTP to ${widget.email}");
}
}
Future _verifyOTP() async {
bool verified = _emailAuth.validateOtp(
userOtp: otpController.text,
recipientMail: widget.email,
);
if (verified) {
// ignore: use_build_context_synchronously
// Navigator.of(context).pushReplacement(
// MaterialPageRoute(builder: () => NamePassword()),
// );
} else {
// ignore: use_build_context_synchronously
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Invalid OTP! Please try again.'),
),
);
}
}
void _resendOTP() {
setState(() {
_sendOTP();
_remainingTime = 60;
_resendButtonDisabled = true;
_isButtonDisabled = true;
});
_startTimer();
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
onPressed: () => Navigator.pop(context),
icon: const Icon(
Icons.arrow_back_ios_rounded,
size: 27,
)),
),
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
'Enter Confirmation Code',
style: TextStyle(
letterSpacing: -0.5,
fontSize: 27,
fontWeight: FontWeight.normal,
color: Colors.black87),
),
const SizedBox(
height: 10,
),
Padding(
padding: const EdgeInsets.only(left: 20, right: 20),
child: Text(
'Enter the confirmation code we sent to ${widget.email}.',
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.black),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: _resendButtonDisabled ? null : _resendOTP,
child: Text(
'Resend Confirmation Code $_remainingTime',
style: const TextStyle(color: Colors.blue),
),
),
],
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.only(left: 30, right: 30),
child: TextFormField(
autofocus: true,
cursorColor: ColorManager.teal,
style: getNormalStyle(
color: Theme.of(context).focusColor, fontSize: 15),
decoration: InputDecoration(
hintText: 'Verify code',
hintStyle: isThatMobile
? getNormalStyle(
color: Theme.of(context).indicatorColor)
: getNormalStyle(
color: ColorManager.black54, fontSize: 12),
filled: true,
focusedBorder: outlineInputBorder(),
enabledBorder: outlineInputBorder(),
errorStyle: getNormalStyle(color: ColorManager.red),
contentPadding: EdgeInsets.symmetric(
horizontal: 10, vertical: isThatMobile ? 15 : 5),
),
controller: _otpController,
keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Verification code is required.';
}
return null;
},
onChanged: (value) {
setState(() {
_isButtonDisabled = value.length < 6;
});
},
),
),
const SizedBox(height: 5),
Padding(
padding: const EdgeInsets.only(left: 5, right: 5, top: 10),
child: CustomElevatedButton(
isThatSignIn: true,
isItDone: true,
nameOfButton: 'Next',
onPressed: () async {
// _isButtonDisabled ? null : verifyOTP;
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: () => NamePassword(
emailcontroller: widget.emailcontroller,
)),
);
},
),
),
const SizedBox(height: 20),
],
),
),
),
);
}
OutlineInputBorder outlineInputBorder() {
return OutlineInputBorder(
borderRadius: BorderRadius.circular(isThatMobile ? 5.0 : 1.0),
borderSide: BorderSide(
color: ColorManager.lightGrey, width: isThatMobile ? 1.0 : 0.3),
);
}
}
Beta Was this translation helpful? Give feedback.
All reactions