Flutter TextField value always uppercase & debounce

Works on Android, iOS, Web, macOS, Windows and Linux You can implement a custom TextInputFormatter class 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

How to add a TextField to Alert in SwiftUI?

Alert is quite limited at the moment, but you can roll your own solution in pure SwiftUI. Here’s a simple implementation of a custom alert with a text field. struct TextFieldAlert<Presenting>: View where Presenting: View { @Binding var isShowing: Bool @Binding var text: String let presenting: Presenting let title: String var body: some View { … Read more

Flutter: Outline input border

What your looking for is – enabledBorder property of InputDecoration. If you want to Change Border on focus use – focusedBorder TextField( decoration: new InputDecoration( focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.greenAccent, width: 5.0), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Colors.red, width: 5.0), ), hintText: ‘Mobile Number’, ), ),

Customizing Increment Arrows on Input of Type Number Using CSS

tl;dr: Having been asked in private about the following setup quite a few times, I decided to add a demo for it (Bootstrap 4 + jQuery + Font Awesome input-group setup): $(‘.btn-plus, .btn-minus’).on(‘click’, function(e) { const isNegative = $(e.target).closest(‘.btn-minus’).is(‘.btn-minus’); const input = $(e.target).closest(‘.input-group’).find(‘input’); if (input.is(‘input’)) { input[0][isNegative ? ‘stepDown’ : ‘stepUp’]() } }) .inline-group { … Read more

How to detect when a TextField is selected in Flutter?

I suppose you are looking for FocusNode. To listen to focus change, you can add a listner to the FocusNode and specify the focusNode to TextField. Example: class TextFieldFocus extends StatefulWidget { @override _TextFieldFocusState createState() => _TextFieldFocusState(); } class _TextFieldFocusState extends State<TextFieldFocus> { FocusNode _focus = FocusNode(); TextEditingController _controller = TextEditingController(); @override void initState() { … Read more

How to detect live changes on TextField in SwiftUI?

You can create a binding with a custom closure, like this: struct ContentView: View { @State var location: String = “” var body: some View { let binding = Binding<String>(get: { self.location }, set: { self.location = $0 // do whatever you want here }) return VStack { Text(“Current location: \(location)”) TextField(“Search Location”, text: binding) … Read more

Flutter textfield background color on focus

It looks like it’s caused by the splash effect on the textfield. I couldn’t find a way to disable it for that specific widget but you can make it transparent by wrapping your TextField in a Theme widget and setting the splashColor to transparent: Theme( data: Theme.of(context).copyWith(splashColor: Colors.transparent), child: TextField( autofocus: false, style: TextStyle(fontSize: 22.0, … Read more

How to debounce Textfield onChange in Dart?

Implementation Import dependencies: import ‘dart:async’; In your widget state declare a timer: Timer? _debounce; Add a listener method: _onSearchChanged(String query) { if (_debounce?.isActive ?? false) _debounce.cancel(); _debounce = Timer(const Duration(milliseconds: 500), () { // do something with query }); } Don’t forget to clean up: @override void dispose() { _debounce?.cancel(); super.dispose(); } Usage In your … Read more