@@ -57,6 +57,9 @@ class _DashboardPageState extends State<DashboardPage> {
5757 children: [
5858 LayoutBuilder (
5959 builder: (context, constraints) {
60+ const tabletBreakpoint = 800 ;
61+ final isNarrow = constraints.maxWidth < tabletBreakpoint;
62+
6063 final summaryCards = [
6164 _SummaryCard (
6265 icon: Icons .newspaper_outlined,
@@ -75,39 +78,27 @@ class _DashboardPageState extends State<DashboardPage> {
7578 ),
7679 ];
7780
78- // Calculate item width for responsive wrapping
79- // Aim for 3 cards per row on wider screens, 2 on medium, 1 on narrow
80- final double totalWidth = constraints.maxWidth;
81- const double minCardWidth =
82- 280 ; // Minimum readable width for a card
83- const double spacing = AppSpacing .lg;
84-
85- // Calculate how many cards can fit in a row
86- int crossAxisCount = (totalWidth / (minCardWidth + spacing))
87- .floor ();
88- if (crossAxisCount == 0 )
89- crossAxisCount = 1 ; // Ensure at least one card
90- if (crossAxisCount > summaryCards.length) {
91- crossAxisCount =
92- summaryCards.length; // Don't exceed number of cards
81+ if (isNarrow) {
82+ return Column (
83+ crossAxisAlignment: CrossAxisAlignment .stretch,
84+ children: [
85+ summaryCards[0 ],
86+ const SizedBox (height: AppSpacing .lg),
87+ summaryCards[1 ],
88+ const SizedBox (height: AppSpacing .lg),
89+ summaryCards[2 ],
90+ ],
91+ );
9392 }
94-
95- final double itemWidth =
96- (totalWidth - (spacing * (crossAxisCount - 1 ))) /
97- crossAxisCount;
98-
99- return Wrap (
100- spacing: spacing, // Horizontal space between cards
101- runSpacing: spacing, // Vertical space between rows
102- alignment: WrapAlignment .start,
103- children: summaryCards
104- .map (
105- (card) => SizedBox (
106- width: itemWidth,
107- child: card,
108- ),
109- )
110- .toList (),
93+ return Row (
94+ crossAxisAlignment: CrossAxisAlignment .start,
95+ children: [
96+ Expanded (child: summaryCards[0 ]),
97+ const SizedBox (width: AppSpacing .lg),
98+ Expanded (child: summaryCards[1 ]),
99+ const SizedBox (width: AppSpacing .lg),
100+ Expanded (child: summaryCards[2 ]),
101+ ],
111102 );
112103 },
113104 ),
0 commit comments