Flutter_Pinput
Flutter_Pinput copied to clipboard
Duplicate keys found [Ios] [Android]
Duplicate keys found is thrown while typing quickly in both Android and Ios emulators using this code:
Pinput(
length: 4,
pinAnimationType: PinAnimationType.none,
controller: controller,
focusNode: focusNode,
showCursor: false,
autofocus: true,
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
defaultPinTheme: PinTheme(
width: 30,
height: 30,
decoration: BoxDecoration(),
),
preFilledWidget: _preFilledCircle(),
obscureText: true,
obscuringWidget: _filledCircle(),
onCompleted: (text) {// Do stuff}
)
Hi @apiorno, unfortunately, I'm not able to reproduce the issue, could you provide more info?
Hi, this isolated code example reproduces the problem:
@override
Widget build(BuildContext context) {
var controller = TextEditingController();
return Scaffold(
body:
Column(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 125.0, vertical: 12.0),
child: Pinput(
length: 6,
pinAnimationType: PinAnimationType.none,
controller: controller,
focusNode: FocusNode(),
showCursor: false,
autofocus: true,
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
defaultPinTheme: const PinTheme(
width: 30,
height: 30,
decoration: BoxDecoration(),
),
preFilledWidget: Container(
width: 13.0,
height: 13.0,
decoration: BoxDecoration(
color: Colors.transparent,
shape: BoxShape.circle,
border: Border.all(
color: Colors.black,
width: 1,
),
),
),
obscureText: true,
obscuringWidget: Container(
width: 13.0,
height: 13.0,
decoration: BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
border: Border.all(
color: Colors.black,
width: 1,
),
),
),
onCompleted: (text) => controller.clear(),
))
]),
);
}
I'm sorry for the late reply, I'm pretty sure you solved the issue on your own, one thing to keep in mind, you should create a controller outside of build method, in the statefullWidget
, and dispose it.
final pinController = TextEditingController();
@override
void dispose() {
pinController.dispose();
super.dispose();
}
Closing this issue, feel free to reopen it if you need to.