import 'package:flutter/services.dart';
import 'package:share/share.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:math';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Factsy - Facts about Everything',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
backgroundColor: Colors.grey[100],
appBar: AppBar(
backgroundColor: Colors.blueAccent,
title: Center(child: Text("Categories", style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold,),)),
),
body: SafeArea(
child: ListView.builder(
itemCount: Category.categories.length,
itemBuilder: (context, index) {
return Container(
color: Colors.grey[50],
margin: EdgeInsets.symmetric(horizontal: 3, vertical: 3),
child: ListTile(
leading: Category.categories[index].icon,
title: Text(Category.categories[index].name,
style: TextStyle(
fontSize: 25,
),
),
onTap: (){
Navigator.push(context, MaterialPageRoute(
builder: (context) => Scaffold(
backgroundColor: Colors.grey[100],
appBar: AppBar(
backgroundColor: Colors.blueAccent,
title: Center(child: Text(Category.categories[index].name,
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),
)
),
),
body: ListView.builder(
itemCount: Category.categories[index].facts.length,
itemBuilder: (context, ind){
return Container(
color: Colors.grey[50],
margin: EdgeInsets.symmetric(horizontal: 4, vertical: 5),
child: ListTile(
title: Text(Category.categories[index].facts[ind],
style: TextStyle(
fontSize: 25,
),
),
leading: Text((ind + 1).toString(),
style: TextStyle(
fontSize: 20
),
),
onTap: (){
Navigator.push(context, MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(
backgroundColor: Colors.lightBlue,
title: Center(
child: Text(Category.categories[index].name,
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),),
),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: Text(
(ind + 1).toString() + '/' + Category.categories[index].facts.length.toString(),
style: TextStyle(
fontSize: 70,
fontWeight: FontWeight.bold
),
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Center(
child: Text(
Category.categories[index].facts[ind],
style: TextStyle(
fontSize: 30,
fontStyle: FontStyle.italic
),
),
),
),
],
),
bottomNavigationBar: BottomAppBar(
color: Colors.grey[50],
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
icon: Icon(Icons.loop),
onPressed: (){
Random rng = new Random();
int num = rng.nextInt(Category.categories[index].facts.length);
setState(() {
ind = num;
});
},
),
IconButton(
icon: Icon(Icons.content_copy),
onPressed: (){
Clipboard.setData(ClipboardData(text: Category.categories[index].facts[ind]));
Toast.show('Copied to Clipboard', context, duration: Toast.LENGTH_SHORT, gravity: Toast.BOTTOM);
},
),
IconButton(
icon: Icon(Icons.share),
onPressed: (){
Share.share(Category.categories[index].facts[ind]);
},
),
],
),
),
)
),
);
},
),
);
},
),
)
)
);
},
),
);
},
),
),
),
);
}
}
class Category{
var facts = [];
String name;
Icon icon;
static Category internet = Category('Internet', Icon(Icons.language), ['Netflix is responsible for 15% of global Internet traffic.', 'Symbolics.com was the first registered domain.', 'The first YouTube video to be uploaded was “Meet At Zoo” at 8:27 p.m. on Saturday, April 23, 2005, by Jawed Karim.', 'The first tweet was sent on March 21, 2006 by Jack Dorsey.', " The world’s first website, which is info.cern.ch is still online.", "Twitter was earlier known as Twttr.", "China has treatment camps for Internet addicts.", '30,000 websites are hacked every day.', 'Researchers are debating on addingInternet addiction to the list of mental disorders.', 'Over 100,000 new dot com domains are registered on the web every day.', '70% of all emails sent are spam.', 'Search Engines can only access 0.03% of the Internet. The rest is known as the "deep web."', '80% of information stored on all computers in the world is in English.', "There's high-speed Internet on the way up to Mount Everest.", "The majority of Internet traffic is not generated by humans, but bots like Google and Malware.", '50% of Internet users will quit waiting for a video to load after 10 seconds.']);
static Category technology = Category('Technology', Icon(Icons.computer), ['World’s first 1 GB hard drive was announced by IBM in 1980. Its price was of \$40,000!', '30th November is known as “Computer Security Day“.', "The speed of a computer mouse is measured in 'Mickeys'.", "Creeper, written by Bob Thomas in 1971, is the first computer virus.", "The first electronic computer ENIAC weighed more than 27 tons and took up 1800 square feet.", "The original name of windows was Interface Manager.", "Russians built a computer that ran on water in 1936.", "The first webcam was created in Cambridge to check the status of a coffee pot.", 'The Twitter bird actually has a name – Larry.']);
static Category business = Category('Business', Icon(Icons.business), []);
static Category history = Category('History', Icon(Icons.history), ['In 1924, half the cars in the world were Fords.', 'Nearly 40% of the world lived under Marxist governments in the late 20th Century.', 'Mock naval battles were sometimes held in Rome’s Colosseum.', 'Early helicopters had wooden rotor blades.', 'In World War II, Germany tried to collapse the British economy by dropping millions of counterfeit bills over London.', 'Dentistry Is One of the Oldest Professions, Dating Back to 7000 B.C.', '9 million combatants and 7 million civilians died as a result of WW1.', 'Bin Laden’s death was announced on 1st May 2011. Hitler’s death was announced on 1st May 1945.', 'The world’s most successful pirate in history was a lady, Ching Shih.', 'In the Ancient Olympics, athletes performed naked.', 'It was named the Colosseum because it was next to a statue called the Colossus.', 'Rasputin survived being poisoned and being shot.', 'During World War I, the French built a “fake Paris”', 'Albert Einstein turned down the presidency of Israel.', 'Thomas Edison didn’t invent most of the stuff he patented.', 'The Leaning Tower of Pisa was never straight.', 'During the Victorian period, it was normal to photograph relatives after they died.', 'The shortest war in history, fought between Britain and Zanzibar lasted 38 minutes.', 'People were buried alive so often, that bells were attached to their coffins.', 'Adolf Hitler’s nephew fought against the Nazis in World War II.', 'Abraham Lincoln was a wrestling champion.', 'The guillotine was invented to create “equality in execution”.', 'It’s believed that roughly 97% of history has been lost over time.']);
static Category geography = Category('Geography', Icon(Icons.map), ['Only 5% of the ocean has been explored.', "There Are 7,100+ Islands in the Philippines", "Japan is the world's most earthquake-prone country.", "The Oldest Continuously Inhabited City in the World is Damascus", "Kentucky Has More Caves Than Any Other Place on Earth", "The Deepest Place on Earth Is in the Pacific Ocean", "20% of Oxygen Is Produced by the Amazon forest", "Iceland does not have a railway system.", "Saint Lucia is the only country in the world named after a woman.", 'More people visit France than any other country.', "Indonesia is home to some of the shortest people in the world.", "Sudan Has Almost Twice as Many Pyramids as Egypt", "The Spanish National Anthem Has No Lyrics", "Brazil is named after a tree.", "France is the most depressed country in the world.", "The unicorn is the national animal of Scotland.", "There are only two countries in the world that have the color purple in their flags: Nicaragua and Dominica.", 'Nearly 3% of the ice in Antarctic glaciers is penguin urine.', 'It snowed in the Sahara desert for 30 minutes on the 18th February 1979.', "Finland is the world's happiest country, according to the 2019 World Happiness Report."]);
static Category astronomy = Category('Astronomy', Icon(Icons.wb_sunny), ['Venus spins backward on its axis compared to all the other planets in our solar system.', 'The hottest planet in our solar system is Venus.', 'A light-year is the distance covered by light in a single year.', 'Earth is the only planet not named after a God.', 'Mercury, Venus, Earth & Mars are known as the “Inner Planets”.', 'There are approximately 100 thousand million stars in the Milky Way.', 'The distance between the Sun & Earth is defined as an Astronomical Unit.', 'The first woman in space was a Russian called Valentina Tereshkova.', 'The universe is constantly expanding, getting faster and colder as time passes.', 'The sunset on Mars appears blue.', 'There is no sound in space.', 'The International Space Station completes an orbit of Earth in about 90 minutes.', 'Mercury’s temperature varies from -280° F on its night side to 800° F during the day.', 'A Million Earths Would Fit Inside the Sun', "The Earth Weighs About 13,170,000,000,000,000,000,000,000 Pounds", "Mars appears red to the human eye due to the iron oxide particles that suspends its atmosphere.", "Mercury & Venus are the only 2 planets in our solar system that have no moons.", 'The highest mountain discovered is the Olympus Mons, which is located on Mars.', 'Footprints left on the Moon won’t disappear as there is no wind.', 'There are more volcanoes on Venus than any other planet in our solar system.', 'In our solar system that are 4 planets known as gas giants: Jupiter, Saturn, Uranus & Neptune.', 'There are three main types of galaxies: elliptical, spiral & irregular.', 'Using the naked eye, you can see 3 – 7 different galaxies from Earth.', 'The Hubble Space Telescope is one of the most productive scientific instruments ever built.', 'The center of the Milky Way smells like rum & tastes like raspberries.', 'Gennady Padalka has spent more time in space than anyone else.', 'The center of a comet is called a “nucleus”.', 'In 2006, the International Astronomical Union reclassified Pluto as a dwarf planet.', 'Mars is the most likely planet in our solar system to be hospitable to life.', 'THE MOON WAS ONCE A PIECE OF THE EARTH.', '']);
static Category humanBody = Category('Human Body', Icon(Icons.opacity), ["A single human being's DNA contains as much information as fifty novels.", "During your lifetime, you will produce enough saliva to fill two swimming pools.", 'The average person walks the equivalent of five times around the world in their lifetime.', 'During your lifetime, you will spend around thirty-eight days brushing your teeth.', 'The smallest bone in your body is in your ear, called stapes.', 'A person adds 37 million bacteria to a room every hour.', 'The tongue is the only muscle in one’s body that is attached from one end.', 'Four babies are born every second.', "Nearly two people die each second.", "Yawning Cools Your Brain", "A average human brain operates on about 12-15 watts.", "Polar Bears actually have black skin.", "Roughly 70 percent of an adult's body is made up of water.", "Sitting for more than three hours a day can cut two years off a person's life expectancy.", "Inhaling helium will cause your voice to travel through your vocal cords quicker.", "More than 78% of human brain consists of water.", "By the time you feel thirsty, you've already lost about 1% of your body's water.", "Your tooth enamel is the hardest chemical substance in your body.", "The human body contains enough carbon to produce graphite for about 9,000 pencils.", 'Every 3-4 seconds, around 50,000 cells in your body will die and be replaced by new ones.', 'During the average lifetime, your heart will pump a grand total of 182 million liters of blood.', 'In your mouth alone, there is more bacteria than there are people in the entire world.', 'The average person will walk around 100,000 miles during their lifetime.', 'Walking uses a total of 200 muscles with every step you take.', 'Your brain uses around 20% of the total oxygen and blood in your body.', 'On average, the body takes around 12 hours to totally digest food that you’ve just eaten.', 'Your sense of smell is around 100 times stronger than your sense of taste.', 'The human heart beats around 100,000 times every single day.', 'Every 10 days, your taste buds get replaced.', 'Humans have less genes than a tomato, and worms have just as many genes as humans.', 'When you sneeze, it could potentially travel at 100 miles per hour', 'As well as having faster heart beats, women blink twice as much as men as well.', 'If you weigh 150 pounds, 21 pounds of this is the weight of your skeleton.', 'You could remove your stomach, spleen, one lung, appendix, a kidney, and still survive perfectly fine.', 'Sunburn can permanently damage your blood vessels.', 'The largest blood vessel is the aorta. This is just over an inch in diameter.', 'Although you can’t always remember what the smell is, your nose can remember around 50,000 different scents.', 'The surface area of an adult’s set of lungs is approximately 70 square meters.', 'Your tongue also has a unique pattern and print to it.', 'After a long day at work, you will be around 8mm shorter than you were in the morning.', 'the average person will say around 5,000 words every single day.']);
static Category food = Category('Food and Drink', Icon(Icons.fastfood), []);
static Category animals = Category('Animals', Icon(Icons.pets), ['A lion’s roar can be heard from 5 miles away.', 'Male cats have longer tails than female cats.', 'The world’s loudest bird call can be heard from half a mile away.', 'Cockroaches can live for weeks without their heads.', 'All giant pandas in zoos around the world are on loan from China.', 'The red-billed quelea is the most common bird on Earth.', "Female Lions Do More Hunting Than Males", "There Are More Than a Million Ants For Every Person on Earth", "Elephants Bury Their Dead", "Ostriches Can Outrun Horses.", "Chameleons Change Color Based on Mood, Not Surroundings", "A Giraffe Cleans Its Ears With Its Tongue", "Octopuses have three hearts.", "At birth, a baby panda is smaller than a mouse.", "The color red doesn’t really make bulls angry; they are color-blind.", "Birds are the closest living relatives of crocodilians, as well as the descendants of extinct dinosaurs with feathers", 'If you lift a kangaroo’s tail off the ground it can’t hop.', 'An eagle can kill a young deer and fly away with it.', 'A baby spider is called a spiderling.', 'Nearly 3% of the ice in Antarctic glaciers is penguin urine.', 'Sea otters hold hands when they sleep so they don’t drift away from each other.', 'There has never been a verified snow leopard attack on a human being.', 'The most venomous jellyfish in the world is the Irukandji.', 'Grapes are fatally toxic to cats and dogs – even in small amounts.', 'Adult Mayflies have no functional mouth.', 'There is a type of mouse that howls to defend its territory.', 'Bee stings are acidic while wasp stings are alkaline',]);
static Category plants = Category('Plants', Icon(Icons.local_florist), []);
static Category maths = Category('Mathematics', Icon(Icons.looks_one), []);
static Category chemistry = Category('Chemistry', Icon(Icons.ac_unit), ['A lightning strike may sometimes reach a staggering temperature of 30,000 degrees Celsius (i.e., 54,000 degrees Fahrenheit).', 'Hydrogen is the most abundant element in the Universe', "Coca-Cola initially contained cocaine and hence, the name.", "DNA doesn't catch fire.", "Hot eater freezes quicker than cold water.", "Earth Has Enough Gold to Cover Itself in It", "Vitamin B12 is the toughest total synthesis.", "Olympic gold medals are 95% made of silver and only have around 6g of actual gold.", "Copper has higher electric conductivity than gold.", "The only pure elemental compound that is liquid at room temperature is mercury.", "Alloys are a combination of two or more different kinds of metals.", "There are more water molecules found in a bucket than the estimated number of grains of sand on the planet.", "Astatine is the least abundant element found on earth.", "Talc is the softest material found on earth.", "Blue is the color of liquid oxygen.", "Stale eggs will float in water. Fresh eggs will sink.", "The solid form of carbon dioxide is known as the dry ice.", "Bromine and mercury are the only elements that can stay liquid at room temperature.", "Many radioactive elements do glow in the dark.", "Helium can be frozen only through pressure; not by cooling.", 'Mars is red because its surface contains a lot of iron oxide or rust.', 'The softest known substance known to humankind is talc.', 'Graphene is a better conductor of electricity and heat than any material.']);
static Category sports = Category('Sports', Icon(Icons.pool), []);
static Category psychology = Category('Psychology', Icon(Icons.supervisor_account), ["A gene is the cause of one being negative almost all the time.", "The type of music you listen to has an impact on your perception of the world.", "Having positive and happy people around you can keep you happier.", "Spending money on experiences rather then things have a greater value for you.", "Singing could make you feel less anxious and depressed.", "Thinking in another language makes your decision sound more rational.", "Smart people tend to depreciate themselves.", "Sarcasm is a sign of a healthy brain.", "Having a hobby or passion makes you an overall more attractive peron.", 'Being able to think about how we think is a sign of higher intelligence.', 'If you announce your goals to others, you are less likely to make them happen because you lose motivation, studies confirmed.', 'There are more than 400 distinct phobias well recognized by psychologists.', 'Your favorite song is probably such because you associate it with an emotional event in your life.', 'Spending money on others yields more happiness than spending it on yourself', 'The brain treats rejection like physical pain', "68% of the people suffer from Phantom Vibration Syndrome, the feeling that one's phone is vibrating when it's not.", 'Comedians and funny people are usually more depressed than average, research found.', 'Severe Depression can cause us to biologically age more by increasing the aging process in cells.', 'Crying makes you feel better, reduces stress, and may help to keep the body healthy.', 'Living in sight of water can make you calmer, happier and more creative', 'Phobophobia is the fear of having a phobia.', "People who swear more often are more honest than those who don't", "The Jonah complex is the fear of success which prevents self-actualization.", 'People who stay up late tend to be risk-takers', 'Paraskavedekatriaphobia is the fear of Friday the 13th.']);
static Category celebrities = Category('Celebrities', Icon(Icons.star), []);
static Category music = Category('Music', Icon(Icons.music_note), []);
static Category literature = Category('Literature', Icon(Icons.book), ['The first novel ever written on a typewriter was Tom Sawyer.', 'The longest English word without a vowel is – rhythm.', 'Silent and Listen are spelt with the same letters.', '‘The Mouse Trap’ by Agatha Christie is the longest-running play in history.', '‘Dreamt’ is the only English word that ends in the letters ‘mt’.', 'More people speak Mandarin Chinese than any other language.', "'E' is the most common letter and appears in 11 percent of all english words.", 'J.K. Rowling chose the unusual name “Hermione” so young girls wouldn’t be teased for being nerdy.', 'Bi-weekly has two different definitions: twice a week, or once every two weeks.', '‘Stewardesses’ is the longest word that is typed with only the left hand.', 'Ghosts appear only in 4 Shakespearean plays: Julius Caesar, Richard III, Hamlet and Macbeth.', 'A Language dies every 14 days.', "'Aloha' is a Hawaiian word that means both hello and goodbye.", "There are only four words in the English language which end in ‘dous’: tremendous, horrendous, stupendous, and hazardous."]);
static Category miscellaneous = Category("Miscellaneous", Icon(Icons.loop), ['The lighter was invented way before the match.' ,'80% of mass shooters showed no interest in violent video games, a researcher found.', 'The first alarm clock could only ring at 4 a.m.', 'A single strand of Spaghetti is called a “Spaghetto”.', 'Vanilla flavoring is sometimes made with the urine of beavers.', 'Albert Einstein turned down the presidency of Israel.', 'One man (Tsutomu Yamaguchi) survived both the atomic bombing of Hiroshima and then later Nagasaki.', 'Coca-Cola was the first commercial soft drink that was ever consumed in space.', "The entire world's population could fit inside Los Angeles.", "The world's quietest room is located at Microsoft's headquarters in Washington state.", 'Muhammad is thought to be the most popular name in the world.', 'Copenhagen is the most bike-friendly city in the world.', "The Empire State Building Has Its Own ZIP Code", "Selfies Kill More People Than Sharks", "Olympic Gold Medals Are Only Partially Gold", "Polar Bears have black skin.", "The hashtag symbol is technically called an octothorpe.", "42 Buildings in New York Have Their Own Zip Codes", "The computer control password for US nuclear missiles was 00000000 for 8 years before changing it.", "In France, you can marry a dead person.", 'Facebook, Instagram and Twitter are all banned in China.', "North Korea and Cuba are the only places you can't buy Coca-Cola.", "75% of the world’s diet is produced from just 12 plant and five different animal species.", "Ambivert is the balance between introvert and extrovert.", 'A flock of crows is known as a murder', 'Bananas are curved because they grow towards the sun.', 'Movie trailers were originally shown after the movie, which is why they were called “trailers”.', 'A swarm of 20,000 bees followed a car for two days because their queen was stuck inside.', 'An apple, potato, and onion all taste the same if you eat them with your nose plugged.']);
static List<Category> categories = [miscellaneous, internet, technology, history, geography, astronomy, humanBody, animals, chemistry, psychology, literature];
Category(String name, Icon icon, List<String> facts){
for(int i = 0; i < facts.length; i++){
if(facts[i] == ''){
facts.removeAt(i);
}
}
this.facts = facts;
this.name = name;
this.icon = icon;
}
}
Comments
Post a Comment