Text field becomes very small - flutter

When I click on the text field, the second text field becomes very small

Change the flex value of first expanded widget to 1 instead of 0.
Edit
Remove expanded from both the widgets. In first text field add maxLines : 1 and in second textfield add maxLines : null.

Remove Expanded Widgets from both TextField and Wrap main Column to SingleChildScrollView to avoid getting overFlow errors

Related

Wrap TextField into multiple lines when not in editing mode

I am trying to wrap a TextField into multiple lines when it is not being edited.
The following code works fine while the user is in editing mode:
TextField(
keyboardType: TextInputType.multiline,
maxLines: null,
)
but when the user leaves the page and comes back, the controller's text inside the TextField is fitted on one line, overflowing horizontally - making it hard for a user to append text. How do I get the text of a TextField to wrap on multiple lines when it is not being edited?
If the textfield is inside a row please wrap it with an flexible or sized box widget.
Edit
Add minLines: 1, and maxLines : 20, by the docs setting it to null means its a single line just displayed in different lines.. setting a minLine and maxLines should work

How to set position label text in TextFormField in outlineborder?

How to set position label in TextFormField in outlineborder?
i want set text position. Because, label prefer to bottom not center in border
According to the documentation for the label
Text that describes the input field.
When the input field is empty and unfocused, the label is displayed on
top of the input field (i.e., at the same location on the screen where
text may be entered in the input field). When the input field receives
focus (or if the field is non-empty), the label moves above (i.e.,
vertically adjacent to) the input field.
So, basically this is the behavior for the label. If you want something else you have to make it on your own ( using a Stack widget with a TextField and a Text ). But with this solution you have to treat the focus properties as well on your own.
You can use this post as a reference
https://stackoverflow.com/a/58039585/10143503

What is the name of this property in flutter?

how to shift the hint text to border while text field is selected? For example, in this picture hint text 'email or phone' gets shifted to border
FloatingLabelBehavior is the property you are looking for. Just set the floatingLabelBehavior of your TextFormField to floatingLabelBehavior.always. (https://api.flutter.dev/flutter/material/InputDecoration/floatingLabelBehavior.html)

Wrap text in Flutter but take as little space as possible

I'm trying to create a container which contains text that should automatically wrap. This works by wrapping a Expanded around my text. However, I want the container to take up as little width as possible (as wide as the text). As soon as I add Expanded to my container, the container will take up all the space.
Without Expanded, the width is good as long as the text width is smaller than the available width:
---------------------------
| Some text that won't wrap |
---------------------------
With Expanded, the text will wrap, but the container is unnecessarily wide.
--------------------------------------------------------------
| Some text that will wrap |
--------------------------------------------------------------
The Flexible widget takes only the needed space while the Expanded takes all available space.
So in your case. You should use a Flexible widget instead of the Expanded widget you have used.

How can I add line numbers to TextField on Flutter?

I am trying to add line numbers to text field on Flutter, like on any text editors. I have text that overflows to next line, so I want to show where lines start and end.
First way that came to my mind was to separate the screen into two columns, one for line numbers on left and one for right for the textfield. However, due to screen size differences, I can't know when a line will overflow.
Is there any more formal way to do it?
First, initialize a List of TextField and an currentLine integer variables. TextField must contain properties named textInputAction and onEditingComplete. So each time you press enter, it is considered as finished with current TextField, creating a new TextField and add it into List of TextField and will move the focus to the new TextField. Line numbers will be coming from inputDecoration of each TextField and the value will be from currentLine variable. curentLine++ also ran inside onEditingComplete.
Check out this article about LineMetrics.
As you can see, this gives you a list of metadata concerning your rendered text lines. Using the line numbers and the hardBreak attribute together, you can compute the line numbers to display in the left hand column.
you can use TextSelection()
TextSelection selection = TextSelection(baseOffset: 0, extentOffset: text.length);
List<TextBox> boxes = textPainter.getBoxesForSelection(selection);
int numberOfLines = boxes.length;
get numberOfLines in your Text, count, and show for each line.