lokesh-sudhakar / Flutter-OtpScreen

A new Flutter package which helps developer in creating Otp screen with few lines of code.
Other
10 stars 7 forks source link

renderflow occuring #3

Open abhisheksudhir opened 3 years ago

abhisheksudhir commented 3 years ago

image

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, ); } }