From 9bd8b5c374885ccc6a1d0a340165341a8f4f2157 Mon Sep 17 00:00:00 2001 From: zoe Date: Mon, 1 Aug 2022 14:32:42 +0200 Subject: [PATCH] add data json --- assets/data.json | 10 ++++++++++ lib/main.dart | 12 +++++++----- lib/quiz.dart | 30 +++++++++++++++++++++++++++++- pubspec.yaml | 3 ++- 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 assets/data.json diff --git a/assets/data.json b/assets/data.json new file mode 100644 index 0000000..99863cb --- /dev/null +++ b/assets/data.json @@ -0,0 +1,10 @@ +{ + "people": [ + { + "image": "url", + "name": "name", + "senator": "true", + "description": "killed -42 people" + } + ] +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 3135ad5..e139d1e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,11 +13,13 @@ class Senatorialkillers extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: const [Heading(), Quiz()], + body: SingleChildScrollView( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: const [Heading(), Quiz()], + ), ), ), ), diff --git a/lib/quiz.dart b/lib/quiz.dart index 58d0a20..d6791bd 100644 --- a/lib/quiz.dart +++ b/lib/quiz.dart @@ -12,6 +12,34 @@ class Quiz extends StatefulWidget { class _QuizState extends State { @override Widget build(BuildContext context) { - return const Text("quiz"); + return Column( + children: [ + Image.network( + "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Variegated_golden_frog_%28Mantella_baroni%29_Ranomafana.jpg/640px-Variegated_golden_frog_%28Mantella_baroni%29_Ranomafana.jpg?download"), + const AnswerButtons(), + ], + ); + } +} + +class AnswerButtons extends StatelessWidget { + const AnswerButtons({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + TextButton.icon( + onPressed: null, + icon: const Icon(Icons.how_to_vote), + label: const Text("Senator"), + ), + TextButton.icon( + onPressed: null, + icon: const Icon(Icons.gavel), + label: const Text("Serial Killer"), + ) + ], + ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 4d5b8f7..7107434 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -58,7 +58,8 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: + assets: + - assets/data.json # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg