I’m new to Flutter and trying to build a simple UI but running into problems. I built an ink space with icons. My problem is that I can’t get the folder icon to the left.
My code:
Container(
width: MediaQuery.of(context).size.width - 20,
padding: EdgeInsets.all(20),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.all(30),
color: Colors.blue,
child: Container(
padding: EdgeInsets.all(20),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
InkWell(
onTap: () {
var personUnderCareIdentifier = "";
if (_personUnderCare.isNotEmpty) {
personUnderCareIdentifier =
_selectedPersonUnderCare
.documentID;
}
},
child: const Text(
"View all",
style: TextStyle(
fontSize: 15,
height: 1.4,
fontWeight: FontWeight.w600,
color: Color.fromRGBO(
14, 113, 176, 1)),
),
),
Column(
children: [
Container(
color: Colors.red,
padding: EdgeInsets.all(20),
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
InkWell(
onTap: () {},
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Image(
height: 70,
image: AssetImage(
"assets/images/folder.png"),
)
],
),
),
],
),
),
],
),
],
),
],
),
],
),
),
),
],
)),
],
),
),
This is the code I made. I hope someone can help me in solving my problem and at the same time can teach me in using flutter. Thank you.
4
Answers
You need to make changes in
mainAxisAlignment
.wrap your container in Align widget and then apply the
Alignment property may it will work because its also work on my side especially in flutter web thank you
If you to do that with
Row
s, you just need to divide yourRow
into two: one for "View all" and one for folder, with different alignment. Here’s your refactored code with this solution:You can also use
Align
widgets instead ofRows
, but that demands some more code refactoring.I was able to modify your code a little in order to achieve your desired aim.
arrangement/nesting.
And that works perfectly!
You can view the screenshot on mobile Here