0%
Quiz — Chapter 59

Chapter 59 — Quiz

Part 1C — Eight Mini-Projects · Chapter 59 of 62 · 12 h

Chapter 59 — Quiz

Level: intermediate Estimated time: 12 h Prerequisites: PART 1A (chapters 01 to 18), PART 1B (chapters 43 to 54), and projects 55 to 58 What you will be able to do by the end: build a complete quiz app — a question bank in JSON embedded in the assets, asynchronous loading, a pure and testable quiz engine, a per-question countdown, immediate visual feedback, animated transitions, a detailed results screen, a persistent best score, and automated tests.


59.0 — Chapter Objectives

By the end of this chapter, you will be able to:

  • model a multiple-choice question with a difficulty enum (recap of chapter 11);
  • write a defensive fromJson that rejects a malformed question (recap of chapters 13 and 17);
  • store a question bank in JSON format in the assets and declare it in pubspec.yaml (recap of chapter 47);
  • load a text asset asynchronously with rootBundle.loadString (recap of chapter 15);
  • write a quiz engine as a pure class, with no dependency on Flutter;
  • display a home screen with a choice of category and number of questions;
  • build a readable, reusable question screen;
  • write an answer button that changes appearance across five states;
  • give immediate visual feedback, green or red, without ever blocking the interface;
  • display an explanation after each answer;
  • animate a progress bar with TweenAnimationBuilder;
  • manage a per-question countdown with Timer.periodic (recap of chapter 45);
  • treat time expiration as an answer in its own right;
  • chain questions together with an AnimatedSwitcher transition;
  • shuffle questions and answers with shuffle, and make that shuffle testable;
  • build a results screen with a message tailored to the score;
  • display a question-by-question summary;
  • persist the best score per category with shared_preferences (recap of chapter 54);
  • move all state, timer included, into a ChangeNotifier exposed by provider (recap of chapter 52);
  • make the app usable with a screen reader and correct in dark mode (recap of chapter 51);
  • write unit tests for the scoring logic and the shuffle.

Comments

Comments are powered by GitHub Discussions

Sign in with GitHub to join the discussion

Link copied!