Title: How I should assign an image property for quiz app
Tags: flutter;image
Question: I'm new to Flutter/Dart and trying to develop a quiz app with images for children to learn the time. In plans to have a picture of watches and several answers below with text answers where the only one is correct. I watched out some tutorial regarding quiz apps but mostly all are about text questions. Thus I can't realize how to use an image as an object property to be able to connect image with answer variants. So, I stuck on this and appreciate any help (direction) from your side. Thanks in advance.
P.S.: I assume some code is excessive because was taken from the tutorials. Sorry for such mess.
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage&gt; createState() =&gt; _MyHomePageState();
class _MyHomePageState extends State<MyHomePage&gt; {
final _itemImage = [
Image.asset('images/1.png'),
Image.asset('images/2.png'),
Image.asset('images/3.png'),
Image.asset('images/4.png'),
int index = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Center(
child: Text('Check time'),
),
),
body: Column(
children: [
Container(
margin:
const EdgeInsets.only(top: 25, bottom: 45, right: 45, left: 45),
child: _itemImage[index],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.deepPurple,
primary: Colors.white60,
),
onPressed: () {
setState(
() {
index = 0;
},
);
},
child: const Text(
&quot;Button 1&quot;,
style: TextStyle(fontSize: 24, color: Colors.white60),
),
),
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.deepPurple,
primary: Colors.white60,
),
onPressed: () {
setState(
() {
index = 0;
},
);
},
child: const Text(
&quot;Button 2&quot;,
style: TextStyle(fontSize: 24, color: Colors.white60),
),
),
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.deepPurple,
primary: Colors.white60,
),
onPressed: () {
setState(
() {
index = 0;
},
);
},
child: const Text(
&quot;Button 3&quot;,
style: TextStyle(fontSize: 24, color: Colors.white60),
),
),
],
),
],
),
);
import 'dart:ui';
import 'my_home_page.dart';
class Question {
var imageNum = _itemImage[index];
String questionAnswer1;
String questionAnswer2;
String questionAnswer3;
Question(this.questionImg, this.questionAnswer1, this.questionAnswer2,
this.questionAnswer3);
import 'question.dart';
class QuizBrain {
int _questionNumber = 0;
List<Question&gt; _questionBank = [
Question('19:00', '20:00', '12:40'),



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2022:00:06/22/22', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<flutter><image>', 'Title': 'How I should assign an image property for quiz app', 'ViewCount': 40, 'id': 72720983, 'user_AboutMe': '', 'user_AccountId': 21666316.0, 'user_DisplayName': 'Fltme', 'user_Reputation': 1.0, 'user_Views': 1.0, 'user_id': 15984639.0}}