small fix

main
Lachfrosch 2024-05-08 16:18:42 +02:00
parent c3dbf3034e
commit 07bcec6fa1
1 changed files with 22 additions and 19 deletions

View File

@ -70,32 +70,35 @@ class _MyHomePageState extends State<MyHomePage> {
_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),
),
),
),
);
},
);
},
),
),
),
);