You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want that when the screen is in view state , the Pinput gains the focus and automatically scrolled down and will visible above soft keyboard , it is working fine when we replace the Pinput with Textfield.
@OverRide
State createState() =>
_OtpVerficationScreenUserState();
}
class _OtpVerficationScreenUserState extends State {
final pinController = TextEditingController();
WhoositApiCaller api = WhoositApiCaller();
Timer? _timer;
int _secondsRemaining = 120; // Initial value for the countdown timer
I want that when the screen is in view state , the Pinput gains the focus and automatically scrolled down and will visible above soft keyboard , it is working fine when we replace the Pinput with Textfield.
To Reproduce
Please find the attached code below-
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pinput/pinput.dart';
import 'package:conf_call_sample/src/networks/api_caller.dart';
import 'package:conf_call_sample/src/utils/toast.dart';
import '../utils/assets_const.dart';
import '../utils/color_constant.dart';
import '../widgets/add_space.dart';
import '../widgets/arc_bg.dart';
import '../widgets/custom_elevated_btn.dart';
import '../widgets/get_app_widget_for_web.dart';
// ignore: must_be_immutable
class OtpVerficationScreenUser extends StatefulWidget {
String login;
bool isNewUser;
OtpVerficationScreenUser(this.login, this.isNewUser, {super.key});
@OverRide
State createState() =>
_OtpVerficationScreenUserState();
}
class _OtpVerficationScreenUserState extends State {
final pinController = TextEditingController();
WhoositApiCaller api = WhoositApiCaller();
Timer? _timer;
int _secondsRemaining = 120; // Initial value for the countdown timer
@OverRide
void initState() {
super.initState();
}
@OverRide
void dispose() {
_timer?.cancel(); // Cancel the timer when the widget is disposed
super.dispose();
}
void startTimer() {
_timer = Timer.periodic(const Duration(seconds: 1), (timer) {
setState(() {
if (_secondsRemaining > 0) {
_secondsRemaining--;
} else {
_timer?.cancel();
}
});
});
}
String getFormattedTime() {
Duration duration = Duration(seconds: _secondsRemaining);
int minutes = duration.inMinutes;
int seconds = duration.inSeconds.remainder(60);
return '$minutes:${seconds.toString().padLeft(2, '0')}';
}
final defaultPinTheme = PinTheme(
width: 56,
height: 56,
textStyle: const TextStyle(
color: mainHeadingText,
fontSize: 18,
fontFamily: fonttFamily,
fontWeight: FontWeight.w400),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(color: hintTextColor),
),
);
@OverRide
Widget build(BuildContext context) {
return Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.centerTop,
floatingActionButton: kIsWeb ? GetAppWidget("") : Container(),
body: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
children: [
Stack(
alignment: Alignment.bottomCenter,
children: [
ClipPath(
clipper: CustomArcPath(),
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 2.1,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [splashColor1, splashColor2],
),
),
),
),
Positioned(
top: 30,
child: Image(
image: const AssetImage(otpVerfication),
height: MediaQuery.of(context).size.height / 3.2,
width: MediaQuery.of(context).size.width / 1.2,
),
),
const FractionalTranslation(
translation: Offset(0.0, 0.22),
child: Image(
alignment: Alignment.center,
image: AssetImage(appLogo),
height: 80,
width: 180,
fit: BoxFit.contain,
))
],
),
const AddVerticalSpace(verticalSpace: 15),
Text(
"otp_verify".tr, //i18n
textAlign: TextAlign.center,
style: const TextStyle(
color: mainTextColor,
fontSize: 26,
fontFamily: fonttFamily,
fontWeight: FontWeight.w700),
),
const AddVerticalSpace(verticalSpace: 15),
Text(
"otp_note".tr, //i18n
textAlign: TextAlign.center,
style: const TextStyle(
fontFamily: fonttFamily,
fontSize: 18,
fontWeight: FontWeight.w400),
),
Text(
"xxxxx-${widget.login.substring(5)}",
textAlign: TextAlign.center,
style: const TextStyle(
fontFamily: fonttFamily,
fontSize: 18,
fontWeight: FontWeight.w400),
),
const AddVerticalSpace(verticalSpace: 35),
Pinput(
controller: pinController,
autofocus: true,
length: 4,
androidSmsAutofillMethod:
AndroidSmsAutofillMethod.smsUserConsentApi,
}
void callApi(String finalOtp) {
if (finalOtp.isEmpty || finalOtp.length != 4) {
showErrorSnackBar("otp_error".tr); //i18n
} else {
api.dioOtpVerifyUser(finalOtp, widget.login, widget.isNewUser);
}
}
}
**Pinput version: - 4.0.0
Result of:
flutter doctor --verbose
Flutter (Channel stable, 3.19.6, on Ubuntu 22.04.4 LTS 6.5.0-35-generic, locale en_IN)
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: