I'm creating a login screen with fields for username and password, but the text always seems a little bit off to the top(see image).
Image of the Issue
How it should look (did with Photoshop)
How can i fix this?
Here is code for the TextFormField:
new Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), child: new TextFormField( maxLines: 1, controller: controller, validator: (value) { if (value.isEmpty) { return 'Please enter username.'; } }, decoration: new InputDecoration( labelText: 'Username', suffixIcon: new IconButton( highlightColor: Colors.transparent, icon: new Container( width: 36.0, child: new Icon(Icons.clear)), onPressed: () { controller.clear(); }, splashColor: Colors.transparent, ), prefixIcon: new Icon(Icons.account_circle)), ), ),
And here is my general theme code, if that helps^^
new ThemeData( fontFamily: 'Product Sans', brightness: Brightness.dark, buttonColor: Colors.green[300], accentColor: Colors.green[300], scaffoldBackgroundColor: Colors.blueGrey[900], canvasColor: Colors.blueGrey[900], textSelectionColor: new Color.fromRGBO(81, 107, 84, 0.8), bottomAppBarColor: Colors.blueGrey[800], primaryColor: Colors.blueGrey[900], indicatorColor: Colors.green[300], cardColor: Colors.white, highlightColor: Colors.green[300], errorColor: Colors.red[400], textSelectionHandleColor: Colors.green[300], splashColor: Colors.white10, buttonTheme: new ButtonThemeData( shape: new RoundedRectangleBorder( borderRadius: new BorderRadius.circular(22.0))), inputDecorationTheme: new InputDecorationTheme( contentPadding: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), border: new OutlineInputBorder( gapPadding: 3.0, borderRadius: new BorderRadius.circular(22.0))), ),
Right-click the text box for which you want to set vertical alignment. On the shortcut menu, click Format Text Box. In the Format Text Box dialog box, click the Text Box tab. In the Vertical alignment box, select Top, Middle, or Bottom.
You can try with contentPadding (.all or .only)
TextFormField( ... decoration: InputDecoration( contentPadding: EdgeInsets.all(10.0), ... )
before
after
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