SwiftUI TextField cursor colour

EDIT: as pointed out below and in the documentation, my original answer (below) is now deprecated and you should use .tint instead. Or if you want all text fields and other UI elements in your app to be the same you can customize your app’s global accentColor. Original answer: Tried it out and .accentColor does … Read more

How to show the Keyboard automatically for a Textfield in Flutter

You can use the autofocus:true property of the TextField: Whether this text field should focus itself if nothing else is already focused. So whenever the widget appears on screen, if theres nothing else with the keyboard focus, the focus will automatically be directed to it, thus opening the keyboard. TextField(TextEditingController: controller, focusNode: focusNode, autofocus:true)

Change TextField’s Underline in Flutter

You can also change its color by following ways. Wrap your TextField in Theme and provide accentColor Theme( data: Theme.of(context).copyWith(accentColor: Colors.red), child: TextField(), ) Using inputDecoration property. TextField( decoration: InputDecoration( focusedBorder: UnderlineInputBorder( borderSide: BorderSide(color: Colors.red), ), ), )

How can I add a bottom line on TextField (SwiftUI)

Divider A visual element that can be used to separate other content. You can set color and height Divider() .frame(height: 1) .padding(.horizontal, 30) .background(Color.red) struct LoginField: View { @State private var email: String = “” @State private var password: String = “” var body: some View { VStack { TextField(“Email”, text: $email) .padding(.horizontal, 30).padding(.top, 20) … Read more

Flutter: Bottom sheet with TextField/TextFormField

You will have to provide a specific width to the TextField, simply provide width in your Container or wrap your Column in Expanded. Solution 1 Container( width: 100, // do it in both Container child: TextField(), ), Solution 2 Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Expanded( // wrap your Column in Expanded child: Column( … Read more

Flutter TextField input only decimal numbers

try this: inputFormatters: [ FilteringTextInputFormatter.allow(RegExp(r”[0-9.]”)), TextInputFormatter.withFunction((oldValue, newValue) { final text = newValue.text; return text.isEmpty ? newValue : double.tryParse(text) == null ? oldValue : newValue; }), ], demo: TextFormField( keyboardType: TextInputType.numberWithOptions( decimal: true, signed: false, ), onChanged: _yourOnChange, inputFormatters: [ FilteringTextInputFormatter.allow(RegExp(r”[0-9.]”)), TextInputFormatter.withFunction((oldValue, newValue) { final text = newValue.text; return text.isEmpty ? newValue : double.tryParse(text) == null … Read more