Skip to content

Commit

Permalink
added math riddle (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamal-kaur04 authored Oct 24, 2020
1 parent 1d982e2 commit f3dd545
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 20 deletions.
10 changes: 10 additions & 0 deletions lib/categories/Math/MathRiddlelLists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:riddleworld/universal/actionCard.dart';
import 'package:riddleworld/universal/riddleAppbar.dart';
import 'math12@Test-User-0123/math12HomePage.dart';
import 'math13@AdityaLalwani/math13HomePage.dart';
import 'math14@kamal-kaur04/math14HomePage.dart';
import 'math9@razorcalhn/math9HomePage.dart';
import 'math10@bibekpanda55/math10HomePage.dart';
import 'math2@Stephen-Odumirin/math2HomePage.dart';
Expand Down Expand Up @@ -171,6 +172,15 @@ class _StateMathRiddles extends State<MathRiddles> {
Navigator.of(context)
.push(MaterialPageRoute(builder: (ctx) => Math13HomeScreen()));
}),
ActionCard(
name: 'Inheritance',
description: 'A math riddle based on the inheritance by @kamal-kaur04',
number: '14',
onPressed: () {
onPlayAudio();
Navigator.of(context)
.push(MaterialPageRoute(builder: (ctx) => Math14HomeScreen()));
}),
];

for (int i = 0; i < cardList.length; i++) {
Expand Down
136 changes: 136 additions & 0 deletions lib/categories/Math/math14@kamal-kaur04/math14HomePage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import 'package:flutter/material.dart';
import 'package:riddleworld/universal/result.dart';
import 'package:riddleworld/universal/riddleAppbar.dart';
import 'package:provider/provider.dart';
import 'package:riddleworld/main.dart';

class Math14HomeScreen extends StatefulWidget {
@override
_Math14HomeScreenState createState() => _Math14HomeScreenState();
}

class _Math14HomeScreenState extends State<Math14HomeScreen> {
int number;
bool _isScore = false;
int totalScore = 0;

void resetHandler() {
setState(() {
totalScore = 0;
_isScore = false;
});
}

@override
Widget build(BuildContext context) {
return RiddleBar(
title: 'Inheritance',
body: _isScore
? Result(totalScore, 1, resetHandler, '/mathPage',
answer: totalScore != 1
? "Wrong answer! Chin up, better luck next time!"
: "Amazing!!! You got it right!!!")
: Center(
child: ListView(
children: <Widget>[
SizedBox(
height: 10,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
border: Border.all(
width: 2,
color: Provider.of<AppStateNotifier>(context,
listen: false)
.isDarkMode
? Colors.white
: Colors.black),
color: Colors.transparent),
width: MediaQuery.of(context).size.width * 0.9,
child: Align(
alignment: Alignment.center,
child: Text(
'Old Granny Adams left half her money to her granddaughter and half that amount to her grandson. She left a sixth to her brother, and the remainder, Dollar 1,000, to the dogs\' home. How much did she leave altogether?',
style: TextStyle(fontSize: 15),
))),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
padding: EdgeInsets.all(8),
width: MediaQuery.of(context).size.width * 0.9,
decoration: BoxDecoration(
border: Border.all(
width: 2,
color: Provider.of<AppStateNotifier>(context,
listen: false)
.isDarkMode
? Colors.white
: Colors.black),
color: Colors.transparent),
child: Column(
children: [
TextField(
decoration: InputDecoration(
labelText: 'Answer',
hintText: 'Enter answer in numbers!!'),
keyboardType: TextInputType.number,
onChanged: (value) => number = int.parse(value),
),
SizedBox(
height: 60,
),
Padding(
padding: const EdgeInsets.only(
top: 10.0, right: 10, left: 10),
child: InkWell(
onTap: () {
if (number == 12000) {
setState(() {
totalScore = 1;
_isScore = true;
});
} else {
setState(() {
totalScore = 0;
_isScore = true;
});
}
},
child: Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
border: Border.all(
width: 2,
color: Provider.of<AppStateNotifier>(
context,
listen: false)
.isDarkMode
? Colors.white
: Colors.black),
color: Colors.transparent),
width: MediaQuery.of(context).size.width * 0.9,
child: Text(
'SUBMIT',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w500,
),
),
),
),
),
],
),
),
),
],
),
),
);
}
}
40 changes: 20 additions & 20 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
version: "2.4.2"
audio_session:
dependency: transitive
description:
Expand All @@ -42,35 +42,35 @@ packages:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.0.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.1.3"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.0.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.3"
version: "1.14.13"
convert:
dependency: transitive
description:
Expand Down Expand Up @@ -98,7 +98,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.1.0"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -218,14 +218,14 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.8"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.1.8"
nested:
dependency: transitive
description:
Expand All @@ -239,7 +239,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
version: "1.7.0"
path_drawing:
dependency: transitive
description:
Expand Down Expand Up @@ -391,49 +391,49 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.2"
version: "1.9.5"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.0.5"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.2"
version: "0.2.17"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.2.0"
url_launcher:
dependency: "direct main"
description:
Expand Down Expand Up @@ -489,7 +489,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.0.8"
win32:
dependency: transitive
description:
Expand All @@ -503,7 +503,7 @@ packages:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
version: "0.1.0"
xml:
dependency: transitive
description:
Expand All @@ -512,5 +512,5 @@ packages:
source: hosted
version: "4.5.1"
sdks:
dart: ">=2.10.0-110 <=2.11.0-185.0.dev"
dart: ">=2.9.0-14.0.dev <3.0.0"
flutter: ">=1.18.0-6.0.pre <2.0.0"

0 comments on commit f3dd545

Please sign in to comment.