Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to paste the verification code? #23

Closed
ScottLee97 opened this issue Aug 23, 2021 · 4 comments
Closed

How to paste the verification code? #23

ScottLee97 opened this issue Aug 23, 2021 · 4 comments

Comments

@ScottLee97
Copy link

I'm trying to copy paste the verification code into the Verification but it is only able to paste the first 2 digits. Does anyone know how to paste all 6 digits? Thanks in advance!

Below is my code:

VerificationCode(
              textStyle: TextStyle(fontSize: 21.0, color: Color(0xff0074e0)),
              underlineColor: Color(0xff0074e0),
              keyboardType: TextInputType.number,
              length: 6,
              // clearAll is NOT required, you can delete it
              // takes any widget, so you can implement your design
              onCompleted: (String value) {
                setState(() {
                  _code = value;
                });
              },
              onEditing: (bool value) {
                setState(() {
                  _onEditing = value;
                });
              },
            ),
@awaik
Copy link
Owner

awaik commented Aug 24, 2021

Thanks to https://github.com/yonatann
this functionality added to the package
PR #24
New version is published here https://pub.dev/packages/flutter_verification_code

@ScottLee97
Copy link
Author

Thank you!

@jose-mca
Copy link

jose-mca commented Mar 8, 2023

Hello, thanks for this awesome package! I'm trying to use the pasting feature. The pasteStream is expecting a Stream<bool>? type. I'm looking at the example code but I couldn't find anything related to this. Do you have anything handy where I could see this?

Thanks!

@awaik
Copy link
Owner

awaik commented Mar 8, 2023

Hi!
Yes, it expects bool, I'll add it to the docs.

For example, in your logic you can use this

  final StreamController<bool> _pasteCode = StreamController<bool>.broadcast();
  Stream<bool> get pasteCode => _pasteCode.stream;
  Sink<bool> get pasteCodeSink => _pasteCode;

Dispose of
await _pasteCode.close();

Button for pasting

FilledButton(
      onPressed: () {
        model.pasteCodeSink.add(true);
      },
      child: Text('Paste'),
    ),

And the widget will look like

VerificationCode(
      ...
      pasteStream: model.pasteCode,
    ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants