Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() {
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- debugShowCheckedModeBanner: false,
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: NoStateHomePage('Zodiac Thingy', secondTitle: "basta naa ni"),
- );
- }
- }
- class NoStateHomePage extends StatelessWidget {
- final String title;
- final String secondTitle;
- NoStateHomePage(this.title, {this.secondTitle});
- // NoStateHomePage(this.title, this.secondTitle);
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text(title + " " + secondTitle),
- ),
- body: ContentZodiac());
- }
- }
- class ContentZodiac extends StatefulWidget {
- @override
- _ContentZodiacState createState() => _ContentZodiacState();
- }
- class _ContentZodiacState extends State<ContentZodiac> {
- int _value = 0;
- List<Map<String, dynamic>> information = [
- {},
- {
- "name": "Aries",
- "dates": "19 April – 13 May",
- "stay": "25 days",
- "brightest_star": "Hamal",
- "image":
- "https://cdn.discordapp.com/attachments/753905152796131328/770286814517919774/scorpio.jpg"
- },
- {
- "name": "Taurus",
- "dates": "14 May – 19 June",
- "stay": "37 days",
- "brightest_star": "Aldebaran",
- "image":
- "https://media.discordapp.net/attachments/753905152796131328/770286818314027048/taurus.jpg?width=789&height=789"
- },
- {
- "name": "Gemini",
- "dates": "20 June – 20 July",
- "stay": "31 days",
- "brightest_star": "Pollux",
- "image": "https://via.placeholder.com/400"
- },
- {
- "name": "Cancer",
- "dates": "21 July – 9 August",
- "stay": "20 days",
- "brightest_star": "Al Tarf",
- "image": "https://via.placeholder.com/400"
- },
- {
- "name": "Leo",
- "dates": "10 August – 15 September",
- "stay": "37 days",
- "brightest_star": "Regulus",
- "image": "https://via.placeholder.com/400"
- },
- {
- "name": "Virgo",
- "dates": "16 September – 30 October",
- "stay": "45 days",
- "brightest_star": "Spica",
- "image": "https://via.placeholder.com/400"
- },
- {
- "name": "Libra",
- "dates": "31 October – 22 November",
- "stay": "23 days",
- "brightest_star": "Zubeneschamali",
- "image": "https://via.placeholder.com/400"
- },
- {
- "name": "Scorpius",
- "dates": "23 November – 29 November",
- "stay": "7 days",
- "brightest_star": "Antares",
- "image":
- "https://cdn.discordapp.com/attachments/753905152796131328/770286814517919774/scorpio.jpg"
- },
- {
- "name": "Ophiuchus",
- "dates": "30 November – 17 December",
- "stay": "18 days",
- "brightest_star": "Rasalhague",
- "image": "https://via.placeholder.com/400"
- },
- {
- "name": "Sagittarius",
- "dates": "18 December – 18 January",
- "stay": "32 days",
- "brightest_star": "Kaus Australis",
- "image": "https://via.placeholder.com/400"
- },
- {
- "name": "Capricornus",
- "dates": "19 January – 15 February",
- "stay": "28 days",
- "brightest_star": "Deneb Algedi",
- "image": "https://via.placeholder.com/400"
- },
- {
- "name": "Aquarius",
- "dates": "16 February – 11 March",
- "stay": "24 days",
- "brightest_star": "Sadalsuud",
- "image":
- "https://cdn.discordapp.com/attachments/753905152796131328/770286395473264660/aquarius.jpg"
- },
- {
- "name": "Pisces",
- "dates": "12 March – 18 April",
- "stay": "38 days",
- "brightest_star": "Eta Piscium",
- "image": "https://via.placeholder.com/400"
- }
- ];
- @override
- Widget build(BuildContext context) {
- return Container(
- padding: EdgeInsets.all(25),
- child: Column(
- children: [
- DropdownButton(
- value: _value,
- items: generateOptions(),
- onChanged: (value) {
- print(value);
- setState(() {
- _value = value;
- });
- }),
- _value == 0
- ? Container()
- : Column(
- children: [
- Image.network(information[_value]["image"]),
- Text("Name of zodiac: ${information[_value]["name"]}",
- style: TextStyle(fontSize: 24)),
- Text("Dates represented: " + information[_value]["dates"]),
- Text(
- "How long it is visible: ${information[_value]["stay"]}"),
- Text(
- "The brightest star: ${information[_value]["brightest_star"]}"),
- ],
- ),
- ],
- ),
- );
- }
- List<DropdownMenuItem<int>> generateOptions() {
- List<DropdownMenuItem<int>> result = [
- DropdownMenuItem(
- child: Text("Select an item"),
- value: 0,
- ),
- ];
- for (int i = 1; i < information.length; i++) {
- result.add(
- DropdownMenuItem(
- child: Text(information[i]["name"]),
- value: i,
- ),
- );
- }
- return result;
- }
- }
Add Comment
Please, Sign In to add comment