I am a flutter beginner. How to create elements like 4*2 tabular columns without borders? I tried, But I didn’t get the alignment I wanted. Like This
can someone guide me on how I can solve this problem? Here is my simplified code for the build method of my stateful widget:
Container(
decoration: BoxDecoration(
border: Border.all(
width: 0.9,
color: Color(0xff908f8f),
),
borderRadius:
BorderRadius.all(Radius.circular(5))),
child: SizedBox(
width: 295.0,
height: 50.0,
child: Row(
children: [
Padding(
padding:
const EdgeInsets.only(top: 10, left: 10),
child: Table(
children: const [
TableRow(children: [
Text(
"1",
style: TextStyle(fontSize: 15.0),
),
Text(
"Mohit",
style: TextStyle(fontSize: 15.0),
),
Text(
"Pre",
style: TextStyle(fontSize: 15.0),
),
Text(
"25",
style: TextStyle(fontSize: 15.0),
),
]),
TableRow(children: [
Text(
"2",
style: TextStyle(fontSize: 15.0),
),
Text(
"Ankit",
style: TextStyle(fontSize: 15.0),
),
Text(
"Pre",
style: TextStyle(fontSize: 15.0),
),
Text(
"27",
style: TextStyle(fontSize: 15.0),
),
]),
],
),
),
],
),
),
),
3
Answers
I think the best way to achieve this layout is to make a row widget containing 4 columns with Text(name) and Text(value) as children.
And then you can style each Column with Container with BoxDecoration.
Wrap Text widgets with Padding or place SizedBox between them with height of your choice.
Try this. This might be the best way to achieve the layout like what you want.
Try below code I have try it Two ways use your choice
Using Widgets:
Create widgets/function and Call
Your Widget:
Result Screen->