Search code examples
flutterflutter-layoutflutter-text

Flutter TextFormField text crops when width exceeds


I am using TextFormField for my flutter application search field. When i type a text bigger that the width of textformfield, then entered text it cropped to half an not visible completely. Please find my below code and attached image for more understanding of problem.

TextFormField(
      focusNode: focusNode,
      controller: textController,
      decoration: InputDecoration(
        border: InputBorder.none,
        icon: Icon(
          Icons.search,
        ),
        hintText: AppStrings.searchCatHint,
        hintStyle: TextStyle(
            fontSize: 17,),
      ),
      autovalidate: true,
      autocorrect: false,
      autofocus: true,
    );

Screen for problem:

enter image description here

Similar problem i have seen in another question also, but no solution provided. Similar issue link

Text display proper with @CarlosSR suggestion. But alignment issue as below.

enter image description here


Solution

  • I found a solution for the issue.

    Problem description: On entering new text, old text should move to left without any problem.

    Solution: I have specified a height for my TextFormField with Wrapping with Container. Code looks like below.

    Container(
    height:40, 
    child: TextFormFiled(...),
    ); 
    

    This worked for me. Thanks a lot for all your responses.