How do I find the contentPadding of a InputDecoration? - flutter

The InputDecoration comes with a predetermined contentPadding and if I want to just move the contents of the InputDecoration a little bit to the left, I will have to override internal contentPadding.
Is it there a way for me to find out what's the value of an InputDecoration contentPadding? I tried the Flutter Inspector, but I can't see anything there at all.

You can always Check file source for values - input_decorator.dart

Related

Is there any way to add padding to ONLY the labelText in the TextFormField?

I am creating a Flutter app and I want to add horizontal padding to ONLY the labelText, not the hintText and the input text, in the TextFormField. I was using contentPadding but it adds padding to everything in the TextFormField. I tried looking for a solution but could not find anything.
I want something like this in the picture, so that the labelText has extra padding on the left as compared to the input text.
contentPadding: const EdgeInsets.left(40.0),

Change TextField InputDecoration LabelText position and CounterText position as suffix

Is there any way to animate LabelText below the TextField?
I am imagining that as soon as textfield becomes focused, the hintText should animate towards HelperText
Another problem, is there any way to set CounterText (I want to use maxVal in TextField, so counterText is updated automatically) as Suffix of Textfield
How shall I approach this ??
Instead of using TextField, you can use TextField or TextFormField and set it's enabled property to false, and use helperText,HintText, Counter Text etc. so it'll act as textfield and you will have all the liberty to use TextFormField too.

Remove default Materiel design paddings

Basically all Material Design Widget have a default minimum padding, as per their documentation.
Is there a way to remove this padding ? For example, a TextFormField while have its label very close to its content, but I haven't found a way to do the same for a DropDownButton, which is annoying since it break the pattern in a form having TextFormFields and DropDownButtons in it.
Many thanks.
Edit :
This question provides the widget I need, which doesn't seem to be well known : DropdownButtonFormField. It adds components like a label, which answers my immediate need.
Are you looking for this ?
TextField(
decoration:InputDecoration(
contentPadding: const EdgeInsets.all(0.0),
isDense:true,
),
EdgeInsetsGeometry contentPadding : The padding for the input decoration's container. [...]
bool isDense : Whether the InputDecorator.child is part of a dense form (i.e., uses less vertical space). default is false

Inspect widget font, margin, padding and other properties

Using flutter inspector I'm not able to find a list of widget's properties like font size, font family, border color, padding, margin ...
For example, in a Text widget the available properties are textDirection, textAlign, size, and a few more, like in screenshot below:
I would like to see all computed properties, like browsers do:
Of course they are different tools, but i would like to know if there is a way to check more properties.
I also found a code-based solution, to access widget properties after it has been rendered, like in this question:
How to get the TextFormField text color,fontsize, etc using controller in flutter?
Is that the best way to achieve the result? Is it possible to use Keys in a way which allows to access widget properties without using a custom widget (i would like to save the reference to a Text, Row, etc. widgets and print all their properties)?
I also tried to use toDiagnosticsNode and toStringDeep methods as follows (_textWidget is of course a Text widget created above, this code is called when i click a button):
var test = _textWidget.toDiagnosticsNode().getProperties();
if (test != null && test.isNotEmpty) {
test.forEach((element) {
print(element.toStringDeep());
});
}
Is it possible to play a bit with a recursive function to get all the properties? All i can see with that code is the text displayed.

How to prevent TextField widget's cursor from jittering? - Flutter

https://imgur.com/X2gEMqO
Check out the video to see what I'm talking about ⤴
Before I start making custom widgets I wanted to see if anyone knew a way to fix this with vanilla Flutter. It seems to be something related to the TextEditingController but I'm not entirely sure.
When the TextField is set to centre or right align it seems to work just fine, but when on left / start / justify it always seems to have that slight jitter.
Thanks in advance! ~ I may post this to the Github repository as well
Edit: You can see that the cursor jitters only when it moves to the left of the textfield. When it is moving within the string it does not jitter at all. I was testing this on a simulated iPhone 11
This problem has two parts to it. First, the cursorOffset of the text_field.dart for whatever reason has a negative x value.
This causes the cursor to be jammed into it's container making the width look weird. Second, the TextStyle.height property causes the cursor to jump.
I figured out how to fix this thanks to Pavel!
TextField - Font Size 50.0 / Height 1.30
https://imgur.com/gallery/G9bkcIf
TextField - Font Size 20.0 / Height 1.30
https://imgur.com/gallery/x7a5nzM
Fix Cursor Offset
The cursorOffset value is stored within the text_field.dart file. In
order to edit it, you should probably create a duplicate of the
text_field.dart file to customize. Here's how to do that,
although you might find better answers with a Google
Once you have the file ready to edit navigate to cursorOffset
within TargetPlatform.iOS. It should be around line 924-ish if
your file is unmodified.
Change the values of Offset(...) to 0 & 0 (x, y) respectively or
whatever you think is appropriate.
If you duplicated the text_field.dart file correctly then it should
be working right away!
Fix Cursor Jump
This fix is a lot less work. Simply add in a TextStyle widget to the
style: property of a TextField widget.
Then, just fill in the height property of your TextStyle widget
with whatever you think! I found 1.3 was a good median but pick the
best height for your fontSize. Here's some information on
height:
Github Issue Regarding This
https://github.com/flutter/flutter/issues/31661