Your First Flutter App: Polishing the App

Apr 12 2022 Dart 2.14.1, Flutter 2.5, Visual Studio Code

Part 2: Build Out the App

13. Fix a Bug

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode
See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 12. Add the Score Next episode: 14. Challenge: Track Rounds

This video was last updated on Apr 12 2022

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

Bull’s Eye is coming along well, but there’s a problem: right now, the random target never changes. It’s always the same random value we get when we first start the app.

setState(() {
  _model.totalScore += _pointsForCurrentRound();
  _model.target = Random().nextInt(100) + 1;
});
TextButton(
  child: Text('Hit Me!', style: TextStyle(color: Colors.blue)),
  onPressed: () {
    _showAlert(context);
    setState(() {
      _model.totalScore += _pointsForCurrentRound();
      _model.target = Random().nextInt(100) + 1;
    });
  },
),
onPressed: () {
  Navigator.of(context).pop();
  setState(() {
    _model.totalScore += _pointsForCurrentRound();
    _model.target = Random().nextInt(100) + 1;
  });
},