@@ -266,24 +266,52 @@ class _AccelerometerScreenState extends State<AccelerometerScreen> {
266266 }
267267 : null ,
268268 body: SafeArea (
269- child: Column (
270- children: [
271- Expanded (
272- child: AccelerometerCard (
269+ child: LayoutBuilder (
270+ builder: (context, constraints) {
271+ // Each card needs ~150dp minimum to render its compact
272+ // header + a usable chart. Three cards = ~450dp. If the
273+ // available height falls below that, switch to screen-
274+ // level vertical scrolling with a fixed per-card height
275+ // so nothing overflows. Above the threshold we keep the
276+ // current Expanded layout so cards fill the screen.
277+ const double kPerCardMin = 150.0 ;
278+ const double kPerCardScrollHeight = 220.0 ;
279+ final double available = constraints.maxHeight;
280+ final bool needsScroll = available < kPerCardMin * 3 ;
281+
282+ final List <Widget > cards = [
283+ AccelerometerCard (
273284 color: xOrientationChartLineColor,
274285 axis: appLocalizations.xAxis),
275- ),
276- Expanded (
277- child: AccelerometerCard (
286+ AccelerometerCard (
278287 color: yOrientationChartLineColor,
279288 axis: appLocalizations.yAxis),
280- ),
281- Expanded (
282- child: AccelerometerCard (
289+ AccelerometerCard (
283290 color: zOrientationChartLineColor,
284291 axis: appLocalizations.zAxis),
285- ),
286- ],
292+ ];
293+
294+ if (needsScroll) {
295+ return SingleChildScrollView (
296+ physics: const ClampingScrollPhysics (),
297+ child: Column (
298+ children: [
299+ for (final card in cards)
300+ SizedBox (
301+ height: kPerCardScrollHeight,
302+ child: card,
303+ ),
304+ ],
305+ ),
306+ );
307+ }
308+
309+ return Column (
310+ children: [
311+ for (final card in cards) Expanded (child: card),
312+ ],
313+ );
314+ },
287315 ),
288316 ),
289317 );
0 commit comments