Get image and text side by side flutter - 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 ✔️

Related

How to align Text next to TextFormField in 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: [
...
],
),

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.

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

How to set the image position relatively

It is Flutter Layout basic question.
So far, I put a few images use Row.
However I want to do is putting image at 'right bottom' and 'left bottom'.
How can I accomplish this by Flutter layout system?
Row(
children: [
Image.asset('images/pic1.png',
height:50,
left:50, // this member doesnt exist.
bottom:10// this member doesnt exist.
),
Image.asset('images/pic2.png',
height:50
right:50,// this member doesnt exist.
bottom:10,// this member doesnt exist.
)
]
),
You can use Align. For example, for bottom right, you can do like this:
Align(
alignment: Alignment.bottomRight,
child: YourWidget(),
)
Be aware that Align fills all the space it can get so you might want to constrain it within a SizedBox or Container!
Here's everything you need to know about the Alignment class, which is what you pass to the alignment parameter of Align constructor.

Flutter row overflfow with list

I have a list I'm mapping:
List<Widget> names = post.names
.map(
(c) => new Padding(
padding: EdgeInsets.all(8),
child: new Text('' + c['name']),
),
)
.toList();
And displaying:
new Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: names,
),
However, the row overflows to right if it has too many items in it. I tried to wrap it to Expanded / Flexible widgets, but that causes error about the parent widget not having height.
If I try to use:
crossAxisAlignment: CrossAxisAlignment.stretch,
I get:
BoxConstraints forces an infinite height.
I also tried to use Expanded inside the Row, however that is not possible as I'm creating the children from the list and that causes error.
How to achieve a name list which also expands vertically based to amount of items?
You need to use Wrap instead of Row like this.
Wrap(
children: names,
//...
),
If you want the widgets to be scrollable horizontally, use a list view and set the axis to horizontal.
But if you want the widgets to wrap, then you need to build a grid instead of a row.
Check out this post: Flutter - Layout a Grid