Building A Simple Mobile Trivia Game With Flutter

Building this trivia game using Flutter was a fun, engaging and rewarding experience. With the right tools and techniques, we created a wonderful app that engages users and challenges their knowledge.

Steps in Building the Game

  1. Set up the Development Environment by installing flutter in any code editor of your choice.

  2. Install the necessary dependencies if there are any.

  3. Implement the design or User Interface.

  4. After designing the user interface, you can start adding functionality to the game. This involves creating the logic that will power the game. Determine the rules of the game, how points will be scored, how users will advance through levels, and how questions will be generated.

  5. Creating the database: To store the questions and other game data, you need to create a database. You can use Firebase, MySQL, or any other database platform that works with Flutter.

Features of U-Smart Trivia Game

Our Mobile Trivia game was titled, 'U-Smart'. It was built by a team of Mobile developers, Data analysts, Designers, a Frontend Engineer, and a Project Manager.

U-Smart is a trivia game that consists of different questions with the purpose of testing a user’s intellect and general knowledge. The game is intuitive, didactic, and engaging.

A Splash Screen: The app opens with a splash screen that prompts users for their name.

Questions Display: The questions are displayed and the correct or incorrect answers pop up depending on which option a player chooses.

Score Display: The game ends when the players answer all the questions and their score is displayed as well: The app opens with a splash screen that displays the logo and a loading animation.

My Contributions To The Project

I co-authored the technical requirements document for our app (U-Smart).

I also built the name display and results screen pages.

I reviewed codes and ensured the game was running.

I assisted my other colleagues in sorting out issues or bugs.

Code Snippet of U-Smart

Since there are many files and folders in this code, here is what the Question file looked like.

class Question {
  final int id, answer;
  final String question;
  final List<String> options;

  Question({this.id, this.question, this.answer, this.options});
}

const List sample_data = [
  {
    "id": 1,
    "question":
    "Flutter is an open-source UI software development kit created by ______",
    "options": ['Apple', 'Google', 'Facebook', 'Microsoft'],
    "answer_index": 1,
  },
  {
    "id": 2,
    "question": "When google release Flutter.",
    "options": ['Jun 2017', 'Jun 2017', 'May 2017', 'May 2018'],
    "answer_index": 2,
  },
  {
    "id": 3,
    "question": "A memory location that holds a single letter or number.",
    "options": ['Double', 'Int', 'Char', 'Word'],
    "answer_index": 2,
  },
  {
    "id": 4,
    "question": "What command do you use to output data to the screen?",
    "options": ['Cin', 'Count>>', 'Cout', 'Output>>'],
    "answer_index": 2,
  },
   {
    "id": 5,
    "question": "Who wrote To Kill a Mockingbird?",
    "options": ['Ernest Hemingway', ' J.D. Salinger', 'Harper Lee', 'William Faulkner'],
    "answer_index": 2,
  },
  {
    "id": 6,
    "question": "What animal is known for being the world's deadliest?",
    "options": ['Mosquito', 'Lion', 'Housefly', 'Hippopotamus'],
    "answer_index": 1,
  },
  {
    "id": 7,
    "question": "Who sang the hit song Shape of You?",
    "options": ['Ed Sheeran', 'Bruno Mars', 'Justin Bieber', 'Drake'],
    "answer_index": 0,
  },
  {
    "id": 8,
    "question": "Who was the first female prime minister of the United Kingdom?",
    "options": ['Jacinda Ardern', 'Angela Merkel', 'Theresa May', 'Margaret Thatcher'],
    "answer_index": 3,
  },
  {
    "id": 9,
    "question": " What is the term for the process by which light waves bounce off a surface and change direction?",
    "options": ['Refraction', 'Reflection', 'Diffraction', 'Absorption'],
    "answer_index": 2,
  },
  {
    "id": 10,
    "question": "What is the title of F. Scott Fitzgerald's most famous novel?",
    "options": ['The Great Gatsby', 'The Catcher in the Rye', '1984', 'Animal Farm'],
    "answer_index": 0,
  },
   {
    "id": 11,
    "question": "Which animal has the longest lifespan?",
    "options": ['Bowhead Whale', 'Greenland Shark', 'Tiger', ' Galapagos Tortoise'],
    "answer_index": 1,
  },
   {
    "id": 12,
    "question": " Which music genre originated in Jamaica in the late 1960s and has influenced many other genres of music?",
    "options": ['Blues', 'Reggae', 'Jazz', 'Hiphop'],
    "answer_index": 1,
  },
  {
    "id": 13,
    "question": "Who was the founder of the Mali Empire in West Africa?",
    "options": ['Shaka Zulu', 'Askia Muhammad', 'Mansa Musa', 'Sundiata Keita'],
    "answer_index": 3,
  },
  {
    "id": 14,
    "question": "Which planet is known as the Blue Planet?",
    "options": ['Mars', 'Jupiter', ' Earth', 'Venus'],
    "answer_index": 2,
  },
{
    "id": 15,
    "question": "Who wrote The Cat in the Hat?",
    "options": ['Dr. Seuss', 'Shel Silverstein', 'Roald Dahl', 'Maurice Send'],
    "answer_index": 0,
  },
  {
    "id": 16,
    "question": "What is the largest land animal in the world?",
    "options": ['Lion', 'Tiger', 'Elephant', 'Whale'],
    "answer_index": 2,
  },
   {
    "id": 17,
    "question": "Which country is not a permanent member of the United Nations Security Council?",
    "options": ['Russia', 'Germany', 'China', 'France'],
    "answer_index": 1,
  },
 {
    "id": 18,
    "question": " Who wrote The Hobbit? ",
    "options": ['J.R.R. Tolkien', 'J.K. Rowling', 'George R.R. Martin', 'Stephen King'],
    "answer_index": 0,
  },
  {
    "id": 19,
    "question": " Which iconic musician was known as The King of Pop? ",
    "options": ['John Lennon', 'Freddie Mercury', 'Michael Jackson', 'Elvis Presley'],
    "answer_index": 2,
  },
   {
    "id": 20,
    "question": " What is the only mammal capable of true flight? ",
    "options": ['Pterodactyl', 'Hawk', 'Flying Squirrel', 'Bat'],
    "answer_index": 3,
  },
];

For the full code, here is the link to the GitHub account:

https://github.com/ADA-Software-Engineering-Program/Usmarts

Summary

Building this trivia game was fun, challenging, and quite didactic.

I also followed up on my fellow team members to be sure everyone is doing what they are supposed to do.