From 07bcec6fa135c4b2a0c5babfa260968a21b0c637 Mon Sep 17 00:00:00 2001 From: Lachfrosch Date: Wed, 8 May 2024 16:18:42 +0200 Subject: [PATCH] small fix --- lib/main.dart | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index fda1406..b0319bf 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -70,32 +70,35 @@ class _MyHomePageState extends State { _grid = List.generate(widget.gridSize, (_) => List.generate(widget.gridSize, (_) => Random().nextInt(5))); } + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Candy Crush'), ), body: Center( - child: GridView.builder( - shrinkWrap: true, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: widget.gridSize, - ), - itemCount: widget.gridSize * widget.gridSize, - itemBuilder: (BuildContext context, int index) { - int row = index ~/ widget.gridSize; - int col = index % widget.gridSize; - return GestureDetector( - onTap: () => _onTileTap(row, col), - child: Container( - margin: EdgeInsets.all(2), - decoration: BoxDecoration( - color: _getColor(_grid[row][col]), - borderRadius: BorderRadius.circular(8), + child: Expanded( + child: GridView.builder( + shrinkWrap: true, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: widget.gridSize, + ), + itemCount: widget.gridSize * widget.gridSize, + itemBuilder: (BuildContext context, int index) { + int row = index ~/ widget.gridSize; + int col = index % widget.gridSize; + return GestureDetector( + onTap: () => _onTileTap(row, col), + child: Container( + margin: EdgeInsets.all(2), + decoration: BoxDecoration( + color: _getColor(_grid[row][col]), + borderRadius: BorderRadius.circular(8), + ), ), - ), - ); - }, + ); + }, + ), ), ), );