I build a row of date with ListView.builder, each listview is a column with Day and Date.
I want it to space evenly in the Row, but mainAxisAlignment: MainAxisAlignment.spaceEvenly
seems only centred the listview :/
Another question is why do I need to wrap the listview builder with a fixed height? It worked but I don't think this is the best approach.
Thanks everyone in advance.
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class TimeSlot extends StatefulWidget {
@override
_TimeSlotState createState() => _TimeSlotState();
}
class _TimeSlotState extends State<TimeSlot> {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
height: 55,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: 8,
itemBuilder: (context, i) {
final weekDay = DateTime.now().add(
Duration(days: i),
);
final day = DateFormat.E().format(weekDay).substring(0, 2);
final date = DateFormat.d().format(weekDay);
return Column(
children: <Widget>[
Text(
day,
style: TextStyle(
color: Color.fromRGBO(30, 41, 51, 0.5),
),
),
SizedBox(
height: 7,
),
CircleAvatar(
backgroundColor: Color.fromRGBO(240, 242, 245, 1),
radius: 14,
child: CircleAvatar(
backgroundColor: Colors.white,
child: Text(
date,
style: TextStyle(color: Colors.black, fontSize: 12),
),
radius: 13,
),
),
],
);
}),
),
],
);
}
}