Doing UI for a flutter app at uni, I just want the text typed into the TextFormField to be white. It seems unnecessarily difficult. I've tried googling etc but can't see an obvious answer.
new Theme( // this colors the underline data: theme.copyWith( primaryColor: Colors.white, hintColor: Colors.transparent, ), child: new Padding( padding: const EdgeInsets.fromLTRB(32.0, 40.0, 32.0, 4.0), child: TextFormField( key: Key('username'), keyboardType: TextInputType.text, controller: usernameController, decoration: InputDecoration( fillColor: Colors.black.withOpacity(0.6), filled: true, border: new OutlineInputBorder( borderRadius: const BorderRadius.all( const Radius.circular(8.0), ), borderSide: new BorderSide( color: Colors.transparent, width: 1.0, ), ), labelText: 'Username', labelStyle: new TextStyle(color: Colors.white, fontSize: 16.0)), style: TextStyle(fontSize: 20.0, color: textTheme.button.color), validator: validateUserName, onSaved: (val) => this.loginFields._username = val), ), ),
Step 1: Locate the file where you have placed the Text widget. Step 2: Inside the Text widget, add the Style parameter and assign the TextStyle widget. Step 3: Inside the TextStyle widget, add the color parameter and set the color of your choice. For example, color: Colors.
2021 answer If you are using a custom theme, you can define the textSelectionTheme and use the TextSelectionThemeData to define cursorColor and highlighted color to your liking.
This will do:
TextFormField( style: TextStyle(color: Colors.white), )
Puedes usar style: TextStyle
body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Form( key: _formKey, child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ TextFormField( TextFormField( controller: field, style: TextStyle(fontSize: 18, color: Colors.red), decoration: const InputDecoration( contentPadding: const EdgeInsets.only( left: 15, top: 8, right: 15, bottom: 0 ), hintText: 'name', ), validator: (value) { if (value.isEmpty) { return 'Please enter some text'; } return null; }, ), ) ] ) ) ] ) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With