Building an AWS Study Buddy App in Flutter

By Davy Raitt, November 2024

I needed a quick way to review multiple-choice questions for AWS certifications without fussing with spreadsheets or random websites. So I built a Flutter quiz app—complete with local data storage, real-time score updates, and an “Endless Mode” challenge. Here’s how it came together, along with some of the issues I faced while building it.


1. Why This App?

I wanted something that would:

Originally, I tried making a simple command-line script, but quickly realized a mobile-friendly interface would be far more enjoyable for daily use.


2. Data Handling & Local Storage

One key feature is using SharedPreferences for high scores and total questions answered. A short snippet:


// Data snippet (under 10 lines)
Future loadHighScore() async {
  final prefs = await SharedPreferences.getInstance();
  setState(() {
    highScore = prefs.getInt('highScore') ?? 0;
  });
  print("Loaded highScore: $highScore");
}

Explanation: This function reads the saved high score from the device. It’s simple but crucial for motivation—I can see my personal best even if I exit the app.


3. The Quiz Logic

My quiz logic reads JSON questions, shuffles them, and then tallies a score. Here’s a small peek at the function that checks if you got an answer correct:


// Checking correctness (under 10 lines)
bool isAnswerCorrect(List correct, List chosen) {
  final correctSet = Set.from(correct);
  final chosenSet  = Set.from(chosen);
  return correctSet.containsAll(chosenSet)
         && chosenSet.containsAll(correctSet);
}

Explanation: We convert answers to sets and compare them, so multi-answer questions can be handled easily (e.g., “A and C”).


4. Explanation Popups

Each time I submit an answer, I show an explanation dialog. If I missed the question, this helps me learn faster.


// Simple dialog snippet (under 10 lines)
showDialog(
  context: context,
  builder: (_) => AlertDialog(
    title: const Text("Explanation"),
    content: Text(currentQuestion.explanation),
    actions: [
      TextButton(
        onPressed: () => Navigator.pop(context),
        child: const Text("OK"),
      )
    ],
  )
);

Explanation: The snippet uses showDialog to pop up a small explanation, then closes on “OK.” This is how I reinforce knowledge on each step.


5. “Endless Mode” Twist

Sometimes I want a quick session. Other times, I want to keep going until I’m totally done or get a question wrong. Here’s the snippet that triggers “endless” behavior if you enable it:


// Endless mode (under 10 lines)
if (!isCorrect && widget.endlessMode) {
  // If you get it wrong once, the quiz ends
  showExplanationAndEndQuiz();
  return;
}

Explanation: If you choose Endless Mode, messing up any question ends the quiz. It’s an extra challenge for me when I’m feeling confident and want a “sudden death” approach to studying.


Challenges & Lessons Learned

One big challenge was making sure the UI stayed smooth when switching between different question sets. I had to shuffle questions properly without repeating them, and also prevent data corruption if a user closed the app mid-quiz.

Another lesson learned was balancing the right amount of detail in each question’s explanation. Too short, and I didn’t learn enough. Too long, and I’d gloss over it. Striking that balance was key.


Wrap-Up

This app turned out to be a great companion for my AWS cert prep. With offline-ready quizzes, trackable high scores, and the variety of short or endless modes, it kept me engaged and let me see my progress clearly. Hopefully, it inspires you to build (and personalize) your own quiz-based study buddy! By now I have passed 4 certifications with it!