small fix
parent
c3dbf3034e
commit
07bcec6fa1
|
@ -70,32 +70,35 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
_grid = List.generate(widget.gridSize, (_) => List.generate(widget.gridSize, (_) => Random().nextInt(5)));
|
_grid = List.generate(widget.gridSize, (_) => List.generate(widget.gridSize, (_) => Random().nextInt(5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text('Candy Crush'),
|
title: Text('Candy Crush'),
|
||||||
),
|
),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: GridView.builder(
|
child: Expanded(
|
||||||
shrinkWrap: true,
|
child: GridView.builder(
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
shrinkWrap: true,
|
||||||
crossAxisCount: widget.gridSize,
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
),
|
crossAxisCount: widget.gridSize,
|
||||||
itemCount: widget.gridSize * widget.gridSize,
|
),
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemCount: widget.gridSize * widget.gridSize,
|
||||||
int row = index ~/ widget.gridSize;
|
itemBuilder: (BuildContext context, int index) {
|
||||||
int col = index % widget.gridSize;
|
int row = index ~/ widget.gridSize;
|
||||||
return GestureDetector(
|
int col = index % widget.gridSize;
|
||||||
onTap: () => _onTileTap(row, col),
|
return GestureDetector(
|
||||||
child: Container(
|
onTap: () => _onTileTap(row, col),
|
||||||
margin: EdgeInsets.all(2),
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
margin: EdgeInsets.all(2),
|
||||||
color: _getColor(_grid[row][col]),
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
color: _getColor(_grid[row][col]),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue