From a12c5618de26069863ce53a16b33b8aec9fb1686 Mon Sep 17 00:00:00 2001 From: rami-a <2364772+rami-a@users.noreply.github.com> Date: Mon, 8 Apr 2019 11:22:19 -0400 Subject: [PATCH] Prevent vertical scroll in shrine by ensuring card size fits the screen (#30455) --- .../lib/demo/shrine/supplemental/product_columns.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart b/examples/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart index 162098571f..589f9c7e68 100644 --- a/examples/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart +++ b/examples/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart @@ -31,10 +31,12 @@ class TwoProductCardColumn extends StatelessWidget { const double spacerHeight = 44.0; final double heightOfCards = (constraints.biggest.height - spacerHeight) / 2.0; - final double heightOfImages = heightOfCards - ProductCard.kTextBoxHeight; - final double imageAspectRatio = (heightOfImages >= 0.0 && constraints.biggest.width > heightOfImages) - ? constraints.biggest.width / heightOfImages - : 33 / 49; + final double availableHeightForImages = heightOfCards - ProductCard.kTextBoxHeight; + // Ensure the cards take up the available space as long as the screen is + // sufficiently tall, otherwise fallback on a constant aspect ratio. + final double imageAspectRatio = availableHeightForImages >= 0.0 + ? constraints.biggest.width / availableHeightForImages + : 49.0 / 33.0; return ListView( physics: const ClampingScrollPhysics(),