I am new in Flutter. I am looking for TextField value to always capitalize but I did not find any resource on that.Another issue is the TextField onChanged event debounce implementation. When I type on TextField it immediately fires onChanged event which is not suitable for my goal. The onChange event will fire after 500ms on every text changed. new TextField( controller: _controller, decoration: new InputDecoration( hintText: 'Search here', ), onChanged: (str) { //need to implement debounce }) 解决方案 Works on Android, iOS, Web, macOS, Windows and LinuxYou can implement a custom TextInputFormatterclass UpperCaseTextFormatter extends TextInputFormatter { @override TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) { return TextEditingValue( text: newValue.text.toUpperCase(), selection: newValue.selection, ); }}Usage:TextField( inputFormatters: [ UpperCaseTextFormatter(), ])Full example 这篇关于Flutter TextField 值总是大写 &去抖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-30 06:56