Flutter TextFormField with icon on container with height

flutter icons
flutter textfield with icon
flutter inputdecoration
flutter textformfield onchanged
postfix icon flutter
flutter textfield height
icon inside border flutter
textformfield trailing icon

I'm trying to recreate this search input but I'm having troubles in keeping it that small, if I add the prefixIcon the height increases and I can't seem to control it.

Here's what I have right now. I'm using a row because I will need to add a button after the input field as well, but that's for later.

Widget _buildSearch() => Container(
          padding: EdgeInsets.all(8.0),
          color: Color(0xFF131313),
          height: 50.0,
          child: Row(
            children: <Widget>[
              Flexible(
                flex: 2,
                child: TextFormField(
                  textAlign: TextAlign.left,
                  style: TextStyle(fontSize: 11.0),
                  decoration: InputDecoration(
                      contentPadding: new EdgeInsets.symmetric(vertical: 0.0),
                      border: InputBorder.none,
                      prefixIcon: Padding(
                        padding: EdgeInsets.all(0.0),
                        child: Icon(
                          Icons.search,
                          color: Colors.grey,
                        ), // icon is 48px widget.
                      ),
                      hintText: 'Search artist, genre, playlist',
                      hintStyle: TextStyle(fontSize: 11.0)),
                ),
              ),
            ],
          ),
        );

you can adjust image size like this

prefixIcon: new Padding(
   padding: const EdgeInsets.only( top: 15, left: 5, right: 0, bottom: 15),
   child: new SizedBox(
            height: 4,
            child: Image.asset(imgname),
   ),
),

Flutter Text Field: How to add Icon inside the border, How do I add an icon to a text field in flutter? To adjust the width, you could wrap your TextField with a Container widget, like so:. Container( width: 100.0, child: TextField() ) I'm not really sure what you're after when it comes to the height of the TextField but you could definitely have a look at the TextStyle widget, with which you can manipulate the fontSize and/or height

You can add height to your hintStyle to avoid this:

hintStyle: TextStyle(fontSize: 11.0, color: Colors.white, height: 3),

About height in TextStyle:

The height of this text span, as a multiple of the font size.

When height is null or omitted, the line height will be determined by the font's metrics directly, which may differ from the fontSize. When height is non-null, the line height of the span of text will be a multiple of fontSize and be exactly fontSize * height logical pixels tall.

How to update flutter TextField's height and width?, How do you increase the height of a TextField in flutter? The Search Bar to Replicate I would like to add the icon in the search bar. Here is my code so far: new TextField( decoration: new InputDecoration( icon: new Icon(Icons.sear

You can use like this

 decoration: InputDecoration(
                  contentPadding: EdgeInsets.only(top:20),
                  border: InputBorder.none,
                  hintStyle: TextStyle(
                    fontFamily: AppTheme.fontName,
                    fontWeight: FontWeight.w600,
                    fontSize: 16,
                    color: AppTheme.deactivatedText,
                  ),

Flutter Clear TextField Text Input Entered Text on Button Click , But, the mandatory minimum height of the prefix and suffix icons In my case i used this helper widget to my TextFormField's prefixIcon, the height of TextField is to wrap TextField in a Container with height: 30 , for example. the default textfield height is too big(the padding of top and bottom too big), i want little size, how can i implementation it? i known InputDecoration.collapsed can remove the space, but it can't use prefix and suffix.

adjust the content padding for the textfield and wrap your icon in padding widget since its input type is Widget

TextField(
      decoration: InputDecoration(
          contentPadding: EdgeInsets.only(top: 20), // add padding to adjust text
          isDense: true,
          hintText: "Email",
          prefixIcon: Padding(
            padding: EdgeInsets.only(top: 15), // add padding to adjust icon
            child: Icon(Icons.help_outline),
          ),

    );

this is the output of above code

flutter/flutter, An icon that appears before the prefix or prefixText and before the editable part of the text field, within the decoration's container. The size and color of the prefix  - Flutter Container height same as parent height - Flutter expand Container to fill remaining space of Row - The equivalent of wrap_content and match_parent in flutter? Since the Row that contains the section Container also has a ListView being generated with the FutureBuilder, the height of the Row automatically expands to fit the ListView.

You can use ListTile, the icon put in leading and TextFormField put in Title.

prefixIcon property - InputDecoration class - material , An icon that appears after the editable part of the text field and after the suffix or suffixText, within the decoration's container. The size and color of the suffix icon  Following is my code where I am trying to add form TextFormField with decoration as seen in mock: Rounded border Background colour to grey First email and then password with text not visible Where

suffixIcon property - InputDecoration class - material , The border, labels, icons, and styles used to decorate a Material Design text field. The TextField displays a "send message" icon to the left of the input area, which is surrounded by a border an all sides. return TextFormField(. 36 contentPadding → EdgeInsetsGeometry: The padding for the input decoration's container. Here’s another answer expanding a bit on @Vilokan Lab’s answer, which wasn’t really doing it for me since FlatButton has a minimum width of 88.0, and thus the clear button was not appearing right-aligned with the TextField at all.

InputDecoration class - material library - Dart API, API docs for the TextFormField class from the material library, for the Dart lifetime should be managed by a stateful widget ancestor of the scrolling container. TextFormField( decoration: const InputDecoration( icon: Icon(Icons.​person),  To retrieve the value when it changes, see the Handle changes to a text field recipe. TextFormField. TextFormField wraps a TextField and integrates it with the enclosing Form. This provides additional functionality, such as validation and integration with other FormField widgets.

TextFormField class - material library - Dart API, Flutter: Underline below TextFormField icon MainAxisSize.max, children: <​Widget>[ new Image.asset('assets/images/avatar.png'), new Container(height: 90.0,  TextFormField, which integrates with the Form widget. InputDecorator , which shows the labels and other visual elements that surround the actual text editing widget. EditableText , which is the raw text editing control at the heart of a TextField .

Comments
  • Hello!You can Try using Icon widget right in the same row.
  • That did it, thanks... feeling dumb lol
  • Flexible( flex: 2, this could be a issue
  • use prefix instead of prefixIcon. That's better than an extra widget in the row, because tapping on the icon will focus the search input.