Created
August 29, 2019 11:16
-
-
Save saitbnzl/601fdd2c61c6bfe3f062c0ef9a67b38e to your computer and use it in GitHub Desktop.
Simple input capitalizer in Dart. You can use it inside InputFormatters in Flutter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/services.dart'; | |
import 'package:paynet/common/utils/index.dart'; | |
class InputCapitalizer extends TextInputFormatter { | |
@override | |
TextEditingValue formatEditUpdate( | |
TextEditingValue oldValue, TextEditingValue newValue) { | |
int selectionIndex = newValue.selection.end; | |
return TextEditingValue( | |
text: newValue.text.toUpperCase(), | |
selection: TextSelection.collapsed(offset: selectionIndex), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Important notice about toUpperCaseMethod:
For example, there is a package for Turkish which solves these character issues of toUpperCaseMethod etc.: https://github.com/ahmetaa/turkish