From 4b59eeaf86b24ce9fee468b4b2534b3a34a3f3cc Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Mon, 10 Jun 2024 15:17:52 +0300 Subject: [PATCH] put trailing at the end, not overlay, so it works on nutrition diary --- lib/widgets/nutrition/nutrition_tile.dart | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/widgets/nutrition/nutrition_tile.dart b/lib/widgets/nutrition/nutrition_tile.dart index f7134f622..4e1cc5b48 100644 --- a/lib/widgets/nutrition/nutrition_tile.dart +++ b/lib/widgets/nutrition/nutrition_tile.dart @@ -2,14 +2,12 @@ import 'package:flutter/material.dart'; /// NutritionTile is similar to a non-interactive ListTile, /// but uses a fixed, easy to understand layout. -/// any trailing value is overlayed over the title & subtitle, on the right -/// as to not disturb the overall layout class NutritionTile extends StatelessWidget { - final Widget? leading; // will always be constrained to 40px wide + final Widget? leading; // always constrained to 40px wide final double vPadding; final Widget? title; final Widget? subtitle; - final Widget? trailing; + final Widget? trailing; // always constrained to 20px wide const NutritionTile({ this.leading, @@ -32,18 +30,18 @@ class NutritionTile extends StatelessWidget { ), const SizedBox(width: 8), Expanded( - child: Stack( + child: Column( children: [ - Column( - children: [ - if (title != null) title!, - if (subtitle != null) subtitle!, - ], - ), - if (trailing != null) Align(alignment: Alignment.centerRight, child: trailing!), + if (title != null) title!, + if (subtitle != null) subtitle!, ], ), ), + const SizedBox(width: 8), + ConstrainedBox( + constraints: const BoxConstraints(minWidth: 20, maxWidth: 20), + child: trailing ?? const SizedBox(width: 20), + ), ], ), );