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.

*Enrollment provides full access to this course (and updates) for life.

Or Signup for Unlimited PRO Access

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,

Q&A Chat