How to align Text next to TextFormField in Flutter? - flutter

I have a Text widget (the +357) next to a TextFormField widget (the 12345678) like here:
They are put in a row (with the icon as well).
The problem is when there is error text in the TextFormField, the error text displaces the TextFormField entirely:
How can I keep the TextFormField in its place even when there is an error text to be displayed??
note: if it turns that showing some code is needed just ask about it, as I think that I explained it clearly above.

Try to add the property crossAxisAlignment: CrossAxisAlignment.start to your row
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
...
],
),

Related

Get image and text side by side flutter

I want to get my AssetImage and Text side by side each other. To achieve that I used a row and it is being displayed like this:
Row(
children: [
Image.asset('assets/images/pfp.png',height: height*0.1,),
Column(children: [Text("we")],)
],
)
I want the image to be displayed in this way:
I want the text to start from the top of the image. How do I achieve that? Below is the current code I have that displayed it as the first image:
Use crossaxisalgnment
Row(
crossAxisAlignment : CrossAxisAlignment.start,
children : [
Image.asset(""),
Text(""),
]
)
Just add a cross axis alignment property to your Row widget
Set it to crossAxisAlignment: CrossAxisAlignment.start
You will have the expected result ✔️

How to prevent failedAssertion: size.isFinite in Flutter

I had a very basic Flutter layout which looked something like this:
Column
widget1
expanded
widget2
This worked great. Widgets 1 and 2 were rendered and my main "expanded" widget was taking the rest of the screen, great!
Next I wanted to add two buttons on each side of my expanded widget. So I tried this:
Column
widget1
Row
button1
expanded
button2
widget2
Now Flutter throws a layout error: failedAssertion: size.isFinite
Reading about it online, people are saying you cannot put an Expanded inside a Row or a Column because they use infinite main axis length, so if the child is also infinite this causes problems. However, I already had Expanded inside a Column and that worked fine! Why is putting it inside a Row problematic?
One SO suggestion was to put mainAxisSize: MainAxisSize.min in the Row, but that does not help.
Some of the other suggestions were to put the widget inside a Container with fixed sizes. This does resolve the error, but now the widget goes off screen. And this sort of defies the whole purpose of Flutter responsive UI. Why would anyone want to create a fixed sized object on a platform where screen sizes vary widely?
What am I doing wrong here? Seems I am misunderstanding something fundamental here...
it works fine and doesn't through any error
Column(
children:[
Container(
height:50,
width:50,
color:Colors.red),
Row(
children:[
Container(
height:50,
width:50,
color:Colors.red),
Expanded(
child:Text('hgdhj hdgakhjgck dgfkejg')
),
Container(
height:50,
width:50,
color:Colors.red),
]),
Container(
height:50,
width:50,
color:Colors.red),
])

How to Keep the elements on ends in Row() widget in flutter?

I am using below Row widget in flutter , which is nested in a Column widget and on screen it appears shared in the screenshot
I want to the Row elements to appear at extreme ends with some padding. How can I do that?
Row(
children: [
SizedBox(width:20,),
Text("Mark ALL READ"),
SizedBox(width:200,),
Text("Clear All"),
],
),
Setting the mainAxisAlignment property of the row to MainAxisAlignment.spaceAround should place the elements on both ends of the row.
To add some padding you should be able to just place the whole Row() widget into a Padding() widget.

Flutter: How to make such Edit text and remove the unexpected layout padding

I'm trying to implement this design:
i'm very beginner to flutter, and what i'm getting is this:
I don't want you guys to get me wrong, i'm not asking for someone to implement this for me.
i need guidance on how to:
remove the layout padding.
make a textview and edit text side by side look like one widget.
remove the space between the edit texts.
implement the CheckBox (i tried a row with check box and text, didn't work)
show a proper arrow in "Sign In" (instead of ->).
just some explanations, guidance and any documentation or tutorial that could be good for my case.
Here is my code
remove the layout padding.
make a textview and edit text side by side look like one widget.
Im not sure of this if your talking about inside TextFormField you can use contentPadding inside InputDecoration. But based on your layout design, you can separate the Label in TextFormField and create your own label text
Row(
children:[
Text("LABEL"),
Expanded(
child: TextFormField(),
)
]
)
4.implement the CheckBox (i tried a row with check box and text, didn't work)
Row(
children: [
Checkbox(
value: isValue,
onChanged: (bool value) {
setState(() {
isValue = value;
});
}),
Text("SOME TEXT"), //Read RichText widget for your design
],
),
For you arrow -> sign in
Try using Icon() widget

How to remove the top bar from flutter date picker

So, basically I want to completely remove the top bar in bluish color which shows the current date and year and start the calendar interface from the white background but I can't figure out how to do it.
Flutter is an open source project which allows you to modify their entire code.
You should take a look at the class _DatePickerDialog and _DatePickerHeader.
Copy the entire code from date_picker.dart and, at line 1020, remove header and that's it.
return Container(
color: theme.dialogBackgroundColor,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
header, // this one is the header
Flexible(child: picker),
actions,
],
),
)
Most likely you should change Flexible for Expanded over your Column.
Here is the official docs showDatePicker