Open abhisheksudhir opened 3 years ago
CODE: import 'package:flutter/material.dart'; import 'package:otp_screen/otp_screen.dart';
import 'package:blog_app/pages/WelcomePage.dart';
class Otp extends StatelessWidget { static const routeName = '/otp-screen';
Future validateOtp(String otp) async { await Future.delayed(Duration(milliseconds: 2000)); if (otp == "123456") { return null; } else { return "Incorrect OTP"; } }
void moveToNextScreen(context) { Navigator.of(context) .pushNamedAndRemoveUntil(WelcomePage.routeName, (route) => false); }
@override Widget build(BuildContext context) { return OtpScreen.withGradientBackground( topColor: Colors.white, bottomColor: Colors.green[200], icon: Icon( Icons.email, color: Colors.green, ), otpLength: 6, validateOtp: validateOtp, routeCallback: moveToNextScreen, title: "OTP Verification", subTitle: "Enter the code sent to your email address", titleColor: Colors.black, themeColor: Colors.black, ); } }
CODE: import 'package:flutter/material.dart'; import 'package:otp_screen/otp_screen.dart';
import 'package:blog_app/pages/WelcomePage.dart';
class Otp extends StatelessWidget { static const routeName = '/otp-screen';
Future validateOtp(String otp) async {
await Future.delayed(Duration(milliseconds: 2000));
if (otp == "123456") {
return null;
} else {
return "Incorrect OTP";
}
}
void moveToNextScreen(context) { Navigator.of(context) .pushNamedAndRemoveUntil(WelcomePage.routeName, (route) => false); }
@override Widget build(BuildContext context) { return OtpScreen.withGradientBackground( topColor: Colors.white, bottomColor: Colors.green[200], icon: Icon( Icons.email, color: Colors.green, ), otpLength: 6, validateOtp: validateOtp, routeCallback: moveToNextScreen, title: "OTP Verification", subTitle: "Enter the code sent to your email address", titleColor: Colors.black, themeColor: Colors.black, ); } }