Quiz Screen

Loading preview

Starting the Flutter app

A showcase of Flutter's quiz screen functionality

Get the source

Add it to your project

Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.

First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.

How it works

One hardcoded question renders through RadioGroup and RadioListTile, with _selected starting at -1. Submit stays disabled until an option is picked. It passes the index to onAnswer and Skip passes null, with a demo SnackBar when onAnswer is omitted. _currentQuestion and _totalQuestions are final, so the title and LinearProgressIndicator stay on 1 of 5, and no correct answer is stored anywhere.

Adapting it

  • Add a question list holding options and the correct index, and make _currentQuestion mutable.
  • In _answer, score the choice, advance, then reset _selected to -1.
  • Treat null as a skip, and show a results screen after _totalQuestions.