Created
October 13, 2019 15:29
-
-
Save Dev-Owl/8c67ec2d3d86f14810125f594b5a01de to your computer and use it in GitHub Desktop.
Main widget part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext contGameOfLifeext) { | |
final screenSize = MediaQuery.of(context).size; | |
_cellSize = Size( | |
screenSize.width / GameOfLife.rowLength, | |
(screenSize.height - kToolbarHeight) / | |
(GameOfLife.worldSize / GameOfLife.rowLength)); | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
actions: <Widget>[ | |
FlatButton( | |
child: Icon(Icons.restore), | |
onPressed:() { | |
if(_game.running) | |
_game.toggleGame(); | |
setState(() { | |
_game.resetWorld(); | |
}); | |
} , | |
) | |
], | |
), | |
body: StreamBuilder<double>( | |
stream: _game.stateController.stream, | |
builder: (context, snapshot) { | |
return GameBoard( | |
GameOfLife.cellMargin, | |
_game.world, | |
GameOfLife.rowLength, | |
cellSize: _cellSize, | |
); | |
}, | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: _toggleGame, | |
tooltip: 'Start/Stop', | |
child: _game.running ? Icon(Icons.pause) : Icon(Icons.play_arrow), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment