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

Unable to enter decimals via keyboard on Android #42

Closed
jamiecollinson opened this issue Nov 19, 2021 · 5 comments · Fixed by #74
Closed

Unable to enter decimals via keyboard on Android #42

jamiecollinson opened this issue Nov 19, 2021 · 5 comments · Fixed by #74

Comments

@jamiecollinson
Copy link

I'm using SpinBox within a component like so:

SpinBox(
  value: _value!.toDouble(),
  min: widget.min,
  max: widget.max,
  step: widget.step,
  decimals: widget.decimals,
  keyboardType: TextInputType.numberWithOptions(decimal: true),
  onChanged: (newValue) {
    setState(() {
      _value = newValue;
    });
    widget.onChanged?.call(newValue);
})

But when I pop the keyboard and enter (e.g.) 6.0 it appears in the spinner as 60 (i.e. the decimal key is ignored) and I have to manually select the decimal part of the number to replace it.

This happens both with and without the manually set keyboardType, which I think shouldn't be necessary as widget.decimals is greater than zero.

Am I missing something obvious? I didn't see anything other than keyboardType in the API docs but apologies if I have!

@jpnurmi
Copy link
Collaborator

jpnurmi commented Nov 19, 2021

Does it only happen on Android? Do you have a chance to try the same code on another platform?

I wonder if it has something to do with the system locale. What kind of language/region/input settings does the device or emulator have?

@jamiecollinson
Copy link
Author

Haven't tried on iOS as it's an Android specific project (with a bunch of platform code so not easy to try). I can try a demo app on iOS if that would help.

Test device is a physical Nokia 5.3, locale is en-uk (other languages are for testing translations for locales we target):

image

@jamiecollinson
Copy link
Author

(In case it helps also seeing the same on a OnePlus 9 Pro also in en-uk which one of the other developers is using)

@xalikoutis
Copy link

Same here both in IOS and Android, i am from Greece el-GR and here we use as decimal , not .

@BenGMiles
Copy link
Contributor

This happens because onChanged is called every time the input is changed (which makes sense, this package listens to the TextController) but as your custom onChanged function updates your value, you end up with a formatted value every time you type on the keyboard. I've created #74 to add an onSubmitted function that you can pass so your value is only updated when you are finished typing.

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

Successfully merging a pull request may close this issue.

4 participants