Closed cviali closed 4 years ago
InputCodeControl
is ChangeNotifier
so you can simply listen change notifications.
InputCodeControl.addListener((){ ... })
Thanks for the help @RomanBase
hello @RomanBase how you doing? I'm using your package but I'm such a beginner with Flutter that I have no idea of how to implement this. I'm seeing that the InputCodeControl has a value getter, a done and a addListener methods but IDK how to use them :( Any help would be rly appreciated.
This is my code.
Thanks in advance.
class CodeInput extends StatelessWidget {
final codeControl = InputCodeControl(
inputRegex: '^[0-9]',
);
@override
Widget build(BuildContext context) {
final h5 = Theme.of(context).textTheme.headline5;
final textTheme = GoogleFonts.poppins(
textStyle: h5.copyWith(
color: kTextColor,
),
);
return InputCodeField(
autofocus: true,
control: codeControl,
count: 4,
spacing: 16,
decoration: InputCodeDecoration(
width: 74,
height: 48,
box: BoxDecoration(
color: Colors.black.withOpacity(0.04),
border: const Border(
bottom: BorderSide(color: Colors.grey),
),
),
focusedBox: BoxDecoration(
color: Colors.black.withOpacity(0.04),
border: const Border(
bottom: BorderSide(color: kPrimaryColor),
),
),
textStyle: textTheme,
),
);
}
}
I solved it like this
final codeControl = InputCodeControl(
inputRegex: '^[0-9]',
);
final VoidCallback onDone;
CodeInput({this.onDone}) {
codeControl.done(onDone);
}
I've been using this lib and the only thing I need right now is a way to track if the value changed. Is there any onChange equivalent in this lib?