Skip to content

Instantly share code, notes, and snippets.

@andrewackerman
Last active February 7, 2020 19:25
Show Gist options
  • Save andrewackerman/c9d680a163ca308f458864a8639d83f1 to your computer and use it in GitHub Desktop.
Save andrewackerman/c9d680a163ca308f458864a8639d83f1 to your computer and use it in GitHub Desktop.
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final questions = [
{
'questionText': 'a',
'answers': [ '1','2','3' ],
},
];
final counter = 0;
final answered = true;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("My First Flutter App"),
),
body: Column(
children: [
Question(
questions[counter]['questionText'],
),
...(questions[counter]['answers'] as List<String>)
.map((answer) {
return Answer(answer, answered);
}).toList()
],
),
),
);
}
}
class Question extends StatelessWidget {
final String text;
Question(this.text);
@override
Widget build(context) {
return Text(text);
}
}
class Answer extends StatelessWidget {
final String text;
Answer(this.text, bool answered);
@override
Widget build(context) {
return Text(text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment