Created
February 28, 2020 13:12
-
-
Save jddeep/fdb0b2ce4cbcd8900d38127d66aa5135 to your computer and use it in GitHub Desktop.
Animal Heads Up Game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
// A game to guess Animals in Heads-Up Game style :) // | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Animals Heads Up', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: AnimalHeadsUp(), | |
); | |
} | |
} | |
class AnimalHeadsUp extends StatefulWidget { | |
@override | |
_AnimalHeadsUpState createState() => _AnimalHeadsUpState(); | |
} | |
class _AnimalHeadsUpState extends State<AnimalHeadsUp> { | |
Map<String, String> guessList = Map(); | |
List<String> animals = List(); | |
void _makeGame() { | |
Map<String, String> game = new Map(); | |
game['dog'] = 'https://i.imgur.com/531ZDFJ.jpg'; | |
game['cat'] = 'https://i.imgur.com/mCYKLFG.jpg'; | |
game['peacock'] = 'https://i.imgur.com/rZarzBD.jpg'; | |
game['lion'] = 'https://i.imgur.com/dzOdz5u.jpg'; | |
game['zebra'] = 'https://i.imgur.com/cH4FTjg.jpg'; | |
guessList = game; | |
animals = guessList.keys.toList(); | |
} | |
@override | |
void initState() { | |
super.initState(); | |
_makeGame(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Center( | |
child: Text("Animal Heads Up"), | |
), | |
), | |
body: Center( | |
child: ListWheelScrollView( | |
perspective: 0.003, | |
diameterRatio: 2, | |
physics: BouncingScrollPhysics(), | |
children: List.generate(animals.length, (i) => i) | |
.map( | |
(m) => Card( | |
clipBehavior: Clip.antiAlias, | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(16), | |
), | |
child: Stack( | |
fit: StackFit.expand, | |
alignment: Alignment.center, | |
children: <Widget>[ | |
Image.network( | |
guessList[animals.elementAt(m).toString()], | |
alignment: Alignment.center, | |
filterQuality: FilterQuality.low, | |
fit: BoxFit.cover, | |
), | |
Positioned( | |
bottom: 40.0, | |
left: 30.0, | |
child: Text( | |
animals.elementAt(m).toString(), | |
style: TextStyle( | |
color: Colors.white, | |
fontSize: 50, | |
fontWeight: FontWeight.bold, | |
), | |
), | |
) | |
], | |
), | |
), | |
) | |
.toList(), | |
itemExtent: MediaQuery.of(context).size.height * 0.8, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment