Quiz State Management Advanced usage of the Provider package

This lesson is available for PRO members or as a single course purchase. Sign-in and choose a plan below.

State Management with Provider

Manage the state of the quiz with the Provider ChangeNotifier.

file_type_dartlang main.dart
import '../services/services.dart';
import 'package:provider/provider.dart';

// Shared Data
class QuizState with ChangeNotifier {
  double _progress = 0;
  Option _selected;

  final PageController controller = PageController();

  get progress => _progress;
  get selected => _selected;

  set progress(double newValue) {
    _progress = newValue;

  set selected(Option newValue) {
    _selected = newValue;

  void nextPage() async {
    await controller.nextPage(
      duration: Duration(milliseconds: 500),
      curve: Curves.easeOut,


Ask questions via GitHub below OR chat on Slack #questions