I am wondering if I can make a text layout like this:

The colons are aligned with each other, and so are the values. I tried using a fixed-width container with space between rows as a child but the value part is not aligned, any idea guys?
Column(
children: [
Container(
width: MediaQuery.of(context).size.width * .4
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Jenis Layanan'),
Text(':')
]
)
)
]
)
>Solution :
Yes you can. I personally use Table for this case.
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
/// Table row widget
TableRow buildTableRow(String title, String value) {
return TableRow(
children: [
// This widget is for the value of first column
Padding(
padding: const EdgeInsets.fromLTRB(8, 4, 8, 4),
child: Text(
title,
),
),
// This widget is for the value of second column
Padding(
padding: const EdgeInsets.all(4),
child: Text(': $value'),
),
],
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
// Creating table
child: Table(
// The [columnWidths] value must be equal with the total column of [buildTableRow]
columnWidths: const {
// Creates the first column width based on intrinsic sizing.
//
// This [IntrinsicColumnWidth()] is expensive, so don't use it too often.
0: IntrinsicColumnWidth(),
// The second column take all the remaining space.
1: FlexColumnWidth(),
},
// This is where to put the [TableRow]
children: [
buildTableRow('Jenis Layanan', 'Tarik Tunai'),
buildTableRow('Bank Tujuan', 'BRI'),
buildTableRow('No Rekening', '0129319201'),
buildTableRow('Nama Pemilik Rekening', 'Adam'),
buildTableRow('Nominal', 'Rp. 10.000'),
],
),
),
),
);
}
}
And this is the output:
