import 'package:flutter/material.dart'; import '../../../config/style.dart'; class OtpInput extends StatelessWidget { final TextEditingController controller; final bool autoFocus; const OtpInput(this.controller, this.autoFocus, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: 40, width: 40, decoration: const BoxDecoration( shape: BoxShape.circle, color: AppStyle.white, boxShadow: [ BoxShadow( color: Colors.black26, blurRadius: 1, offset: Offset( 0.2, 0.5, ), ), ], ), child: Center( // alignment: Alignment.center, child: Padding( padding: const EdgeInsetsDirectional.only(bottom: 7, start: 2), child: TextField( autofocus: autoFocus, textAlign: TextAlign.center, textAlignVertical: TextAlignVertical.top, keyboardType: TextInputType.text, controller: controller, maxLength: 1, cursorColor: Theme.of(context).primaryColor, decoration: const InputDecoration( border: InputBorder.none, counterText: '', hintStyle: TextStyle(color: Colors.black, fontSize: 20.0)), onChanged: (value) { if (value.length == 1) { FocusScope.of(context).nextFocus(); } }, ), ), ), ); } }