Read the commented line to understand my problem
import 'package:flutter/material.dart';
class DemoTest extends StatefulWidget {
const DemoTest({super.key});
@override
State<DemoTest> createState() => _DemoTestState();
}
class _DemoTestState extends State<DemoTest> {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Row(
children: [
//this column sshould start from top
Column(
children: List.generate(300, (index) {
return Text(index.toString());
})),
//this column sshould start from bottom
Column(
children: List.generate(100, (index) {
return Text(index.toString());
})),
//this column again should be start from top
Column(
// mainAxisAlignment: MainAxisAlignment.end,
children: List.generate(100, (index) {
return Text(index.toString());
}))
],
),
);
}
}
what expecting is like:
Column 1 Column 2 Column 3
0 0
1 1
2 2
3 3
4 .
5 .
.
.
100 0 99
. 1
. .
. .
299 99
SingleChildScrollview -> Row -> 3 COLUMNS (Every column has diffrent alignment). Align is not working, cant add expanded because of singleChildScrollView.
Hope i able to explain every thing
>Solution :
You can try this
class _DemoTestState extends State<DemoTest> {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: IntrinsicHeight(
child: Row(
children: [
Column(
children: List.generate(300, (index) {
return Text(index.toString());
})),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: List.generate(100, (index) {
return Text(index.toString());
})),
Column(
children: List.generate(100, (index) {
return Text(index.toString());
}))
],
),
),
);
}
}
To give some explanation. By wrapping the Row in an IntrinsicHeight it makes it that all the Row‘s children will get the height of the heighest child instead of the children becoming as small as possible. This way, putting a mainAxisAlignment to end to the second column will get the desired result.