Initial version of the descriptions and Locations provider

This commit is contained in:
zontreck 2025-03-25 22:22:41 -07:00
parent e5901e62bb
commit 18641d5606
7 changed files with 604 additions and 60 deletions

View file

@ -1,7 +1,7 @@
import 'dart:io';
class Constants {
static const VERSION = "1.0.032525+2026";
static const VERSION = "1.0.032525+2222";
static bool get isMobile => Platform.isAndroid || Platform.isIOS;
//static bool get isMobile => Platform.isAndroid || Platform.isIOS;
}

View file

@ -111,22 +111,16 @@ class _HomeState extends State<Home> {
children: [
Image.asset(
Pokemon.values[index].toDexPath(),
width: Constants.isMobile ? 64 : 198,
height: Constants.isMobile ? 64 : 198,
width: 64,
height: 64,
),
Text(
Pokemon.values[index].printName(proper: true),
style: TextStyle(
fontSize: Constants.isMobile ? 16 : 32,
color: Colors.black,
),
style: TextStyle(fontSize: 16, color: Colors.black),
),
Text(
"#${Pokemon.values[index].id}",
style: TextStyle(
fontSize: Constants.isMobile ? 16 : 32,
color: Colors.black,
),
style: TextStyle(fontSize: 16, color: Colors.black),
),
],
),
@ -136,7 +130,7 @@ class _HomeState extends State<Home> {
},
itemCount: SessionData.highestGenID(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: Constants.isMobile ? 3 : 4,
crossAxisCount: 3,
),
),
),
@ -205,7 +199,6 @@ class _DexEntryState extends State<DexEntry> {
if (_pkmn.extraVariants.isNotEmpty) _pkmn.getVariations(),
SizedBox(height: 32),
if (Constants.isMobile)
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Column(
@ -213,11 +206,16 @@ class _DexEntryState extends State<DexEntry> {
children: _pkmn.getEvolutions(0),
),
),
if (!Constants.isMobile)
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(children: _pkmn.getEvolutions(0)),
),
if (SessionData.enableDescription && _pkmn.dexEntries.isNotEmpty)
Text("Description: ", style: TextStyle(fontSize: 24)),
if (SessionData.enableDescription && _pkmn.dexEntries.isNotEmpty)
_pkmn.printDescription(),
SizedBox(height: 50),
if (_pkmn.locations.isNotEmpty)
Text("Where to find:", style: TextStyle(fontSize: 24)),
if (_pkmn.locations.isNotEmpty) _pkmn.printLocations(),
],
),
),

View file

@ -6,6 +6,7 @@ import 'package:pokedex/filters.dart';
import 'package:pokedex/pokemon.dart';
class SessionData {
static bool enableDescription = true;
static bool darkMode = false;
static int highest = 9;
static int _cachedHighest = -1;
@ -65,7 +66,7 @@ class SessionData {
List<Widget> tmpWidgets = [];
int i = 0;
int end = Constants.isMobile ? 3 : 4;
int end = 3;
for (var digit in ALPHABET) {
tmpWidgets.add(
Image.asset("assets/sprites/unown-${digit.toLowerCase()}.png"),

140
lib/dexMisc.dart Normal file
View file

@ -0,0 +1,140 @@
import 'package:pokedex/pokemon.dart';
/// The route number.
enum GameRoute {
RT1,
RT2,
RT5,
RT24,
RT25,
RT26,
RT27,
RT30,
RT31,
RT34,
RT35,
RT36,
RT37,
RT38,
RT39,
RT204,
ViridianForest(commonName: "Viridian Forest"),
AzaleaTown(commonName: "Azalea Town"),
HexForest(commonName: "Hex Forest"),
LakeOfRage(commonName: "Lake of Rage"),
NationalPark(commonName: "National Park"),
IlexForest(commonName: "Ilex Forest"),
PatternBush(commonName: "Pattern Bush"),
EternaForest(commonName: "Eterna Forest"),
SantaluneForest(commonName: "Santalune Forest"),
MeleMeleMeadow(commonName: "Mele Mele Meadow"),
LushJungle(commonName: "Lush Jungle"),
SpaciousCave(commonName: "Spacious Cave"),
GrasslandCave(commonName: "Grassland Cave"),
SwampyCave(commonName: "Swampy Cave"),
RiverbankCave(commonName: "Riverbank Cave"),
StillWaterCavern(commonName: "Still Water Cavern"),
SunlitCavern(commonName: "Sunlit Cavern"),
BogsunkCavern(commonName: "Bogsunk Cavern"),
PalletTown(commonName: "Pallet Town"),
CeruleanCity(commonName: "Cerulean City"),
// The following mark the pokemon as not usually obtainable
TradeOrMigrate(commonName: "Trade or Migrate from another game"),
BreedOnly(commonName: "Only obtainable via breeding"),
Evolve(commonName: "Evolve another pokemon");
final String commonName;
const GameRoute({this.commonName = ""});
@override
String toString() {
if (commonName == "")
return name;
else
return commonName;
}
}
/// The game's name.
enum Game {
Red,
Blue,
Yellow,
Gold,
Silver,
Crystal,
Ruby,
Sapphire,
FireRed(commonName: "Fire Red"),
LeafGreen(commonName: "Leaf Green"),
Emerald,
Diamond,
Pearl,
Platinum,
HeartGold(commonName: "Heart Gold"),
SoulSilver(commonName: "Soul Silver"),
Black,
White,
Black2(commonName: "Black 2"),
White2(commonName: "White 2"),
X,
Y,
OmegaRuby(commonName: "Omega Ruby"),
OmegaSapphire(commonName: "Omega Sapphire"),
Sun,
Moon,
UltraSun(commonName: "Ultra Sun"),
UltraMoon(commonName: "Ultra Moon"),
LetsGoPikachu(commonName: "Let's Go Pikachu"),
LetsGoEevee(commonName: "Let's Go Eevee"),
Sword,
Shield,
BrilliantDiamond(commonName: "Brilliant Diamond"),
ShiningPearl(commonName: "Shining Pearl");
final String commonName;
const Game({this.commonName = ""});
@override
String toString() {
if (commonName != "")
return commonName;
else
return name;
}
}
/// This represents the location of where to find the Pokemon.
///
/// This location is going to use a Route Enumerable.
///
/// Another object this includes is the game. Not generation, but game.
class Location {
final List<GameRoute> routes;
final Game game;
final Generation gameGen;
final List<Game> additionalGames;
const Location(
this.game,
this.routes,
this.gameGen, {
this.additionalGames = const [],
});
}
/// The PokeDex Entry describing the pokemon
class DexEntry {
final Game game;
final String desc;
final Generation gameGen;
final List<Game> additionalGames;
const DexEntry(
this.game,
this.desc,
this.gameGen, {
this.additionalGames = const [],
});
}

View file

@ -30,6 +30,19 @@ class _filterPage extends State<FilterPage> {
"The PokeDex's filters will allow you to customize what Generations are shown in the app.\n\n** WARNING **\nThis will prevent evolutions from showing up if the Pokemon resides in a future generation.\n\nThe dex entries will also not show the evolution conditions, or catch conditions for disabled generations.",
style: TextStyle(fontSize: 24),
),
SwitchListTile(
value: SessionData.enableDescription,
onChanged: (X) {
SessionData.enableDescription =
!SessionData.enableDescription;
setState(() {});
},
title: Text("Enable Dex Descriptions"),
subtitle: Text(
"Enables or disables the pokedex descriptions for the pokemon",
),
),
SizedBox(height: 50),
SwitchListTile(
value: (SessionData.highest >= 1),
title: Text("Generation 1"),

View file

@ -3,6 +3,7 @@
import 'package:flutter/material.dart';
import 'package:pokedex/Consts.dart';
import 'package:pokedex/Session.dart';
import 'package:pokedex/dexMisc.dart';
enum Generation {
One(1, 151),
@ -150,10 +151,7 @@ class SingleEvolution extends Evolution {
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Constants.isMobile ? Icons.arrow_downward : Icons.arrow_forward,
size: 48,
),
Icon(Icons.arrow_downward, size: 48),
Card(
elevation: 50,
child: SizedBox(
@ -165,11 +163,7 @@ class SingleEvolution extends Evolution {
children: [
Text(printEvolution(), style: TextStyle(fontSize: 16)),
Image.asset(
pkmn.toDexPath(),
width: Constants.isMobile ? 64 : 128,
height: Constants.isMobile ? 64 : 128,
),
Image.asset(pkmn.toDexPath(), width: 64, height: 64),
Text(pkmn.pokemonName, style: TextStyle(fontSize: 24)),
pkmn.getTypeWidgets(),
],
@ -232,10 +226,7 @@ class BranchedEvolution extends Evolution {
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Constants.isMobile ? Icons.arrow_downward : Icons.arrow_forward,
size: 48,
),
Icon(Icons.arrow_downward, size: 48),
Card(
elevation: 50,
child: SizedBox(
@ -250,11 +241,7 @@ class BranchedEvolution extends Evolution {
style: TextStyle(fontSize: 16),
),
Image.asset(
_pkmn.toDexPath(),
width: Constants.isMobile ? 64 : 128,
height: Constants.isMobile ? 64 : 128,
),
Image.asset(_pkmn.toDexPath(), width: 64, height: 64),
Text(_pkmn.pokemonName, style: TextStyle(fontSize: 24)),
_pkmn.getTypeWidgets(),
],
@ -309,16 +296,167 @@ enum Move {
}
enum Pokemon {
Bulbasaur(1, Generation.One, [
Type.Grass,
Type.Poison,
], SingleEvolution(2, 16)),
Bulbasaur(
1,
Generation.One,
[Type.Grass, Type.Poison],
SingleEvolution(2, 16),
locations: [
Location(
Game.Red,
[GameRoute.PalletTown],
Generation.One,
additionalGames: [Game.Blue],
),
Location(Game.Yellow, [GameRoute.CeruleanCity], Generation.One),
Location(
Game.Gold,
[GameRoute.TradeOrMigrate],
Generation.Two,
additionalGames: [Game.Silver, Game.Crystal],
),
Location(
Game.Ruby,
[GameRoute.TradeOrMigrate],
Generation.Three,
additionalGames: [Game.Sapphire, Game.Emerald],
),
Location(
Game.FireRed,
[GameRoute.PalletTown],
Generation.Three,
additionalGames: [Game.LeafGreen],
),
],
dexEntries: [
DexEntry(
Game.Red,
"A strange seed was planted on its back at birth. The plant sprouts and grows with this POKéMON.",
Generation.One,
additionalGames: [Game.Blue],
),
DexEntry(
Game.Yellow,
"It can go for days without eating a single morsel. In the bulb on its back, it stores energy.",
Generation.One,
),
DexEntry(
Game.Gold,
"The seed on its back is filled with nutrients. The seed grows steadily larger as its body grows.",
Generation.Two,
),
DexEntry(
Game.Silver,
"It carries a seed on its back right from birth. As it grows older, the seed also grows larger.",
Generation.Two,
),
DexEntry(
Game.Crystal,
"While it is young, it uses the nutrients that are stored in the seeds on its back in order to grow.",
Generation.Two,
),
DexEntry(
Game.Ruby,
"BULBASAUR can be seen napping in bright sunlight. There is a seed on its back. By soaking up the suns rays, the seed grows progressively larger.",
Generation.Three,
additionalGames: [Game.Sapphire, Game.Emerald],
),
DexEntry(
Game.FireRed,
"There is a plant seed on its back right from the day this POKéMON is born. The seed slowly grows larger.",
Generation.Three,
),
DexEntry(
Game.LeafGreen,
"A strange seed was planted on its back at birth. The plant sprouts and grows with this POKéMON.",
Generation.Three,
),
],
),
Ivysaur(
2,
Generation.One,
[Type.Grass, Type.Poison],
SingleEvolution(3, 32),
previousPokemon: 1,
locations: [
Location(
Game.Red,
[GameRoute.Evolve],
Generation.One,
additionalGames: [Game.Blue, Game.Yellow],
),
Location(
Game.Gold,
[GameRoute.TradeOrMigrate],
Generation.Two,
additionalGames: [Game.Silver, Game.Crystal],
),
Location(
Game.Ruby,
[GameRoute.TradeOrMigrate],
Generation.Three,
additionalGames: [Game.Sapphire],
),
Location(
Game.FireRed,
[GameRoute.Evolve],
Generation.Three,
additionalGames: [Game.LeafGreen],
),
Location(Game.Emerald, [GameRoute.TradeOrMigrate], Generation.Three),
],
dexEntries: [
DexEntry(
Game.Red,
"When the bulb on its back grows large, it appears to lose the ability to stand on its hind legs.",
Generation.One,
additionalGames: [Game.Blue],
),
DexEntry(
Game.Yellow,
"The bulb on its back grows by drawing energy. It gives off an aroma when it is ready to bloom.",
Generation.One,
),
DexEntry(
Game.Gold,
"Exposure to sunlight adds to its strength. Sunlight also makes the bud on its back grow larger",
Generation.Two,
),
DexEntry(
Game.Silver,
"If the bud on its back starts to smell sweet, it is evidence that the large flower will soon bloom.",
Generation.Two,
),
DexEntry(
Game.Crystal,
"The bulb on its back grows as it absorbs nutrients. The bulb gives off a pleasant aroma when it blooms.",
Generation.Two,
),
DexEntry(
Game.Ruby,
"There is a bud on this POKéMONs back. To support its weight, IVYSAURs legs and trunk grow thick and strong. If it starts spending more time lying in the sunlight, its a sign that the bud will bloom into a large flower soon.",
Generation.Three,
additionalGames: [Game.Sapphire],
),
DexEntry(
Game.FireRed,
"There is a plant bulb on its back. When it absorbs nutrients, the bulb is said to blossom into a large flower.",
Generation.Three,
),
DexEntry(
Game.LeafGreen,
"When the bulb on its back grows large, it appears to lose the ability to stand on its hind legs.",
Generation.Three,
),
DexEntry(
Game.Emerald,
"To support its bulb, IVYSAURs legs grow sturdy. If it spends more time lying in the sunlight, the bud will soon bloom into a large flower.",
Generation.Three,
),
],
),
Venusaur(
3,
@ -326,6 +464,81 @@ enum Pokemon {
[Type.Grass, Type.Poison],
null,
previousPokemon: 2,
locations: [
Location(
Game.Red,
[GameRoute.Evolve],
Generation.One,
additionalGames: [Game.Blue, Game.Yellow],
),
Location(
Game.Gold,
[GameRoute.TradeOrMigrate],
Generation.Two,
additionalGames: [Game.Silver, Game.Crystal],
),
Location(
Game.Ruby,
[GameRoute.TradeOrMigrate],
Generation.Three,
additionalGames: [Game.Sapphire, Game.Emerald],
),
Location(
Game.FireRed,
[GameRoute.Evolve],
Generation.Three,
additionalGames: [Game.LeafGreen],
),
],
dexEntries: [
DexEntry(
Game.Red,
"The plant blooms when it is absorbing solar energy. It stays on the move to seek sunlight.",
Generation.One,
additionalGames: [Game.Blue],
),
DexEntry(
Game.Yellow,
"The flower on its back catches the suns rays. The sunlight is then absorbed and used for energy.",
Generation.One,
),
DexEntry(
Game.Gold,
"By spreading the broad petals of its flower and catching the suns rays, it fills its body with power.",
Generation.Two,
),
DexEntry(
Game.Silver,
"It is able to convert sunlight into energy. As a result, it is more powerful in the summertime.",
Generation.Two,
),
DexEntry(
Game.Crystal,
"As it warms itself and absorbs the sunlight, its flower petals release a pleasant fragrance.",
Generation.Two,
),
DexEntry(
Game.Ruby,
"There is a large flower on VENUSAURs back. The flower is said to take on vivid colors if it gets plenty of nutrition and sunlight. The flowers aroma soothes the emotions of people.",
Generation.Three,
additionalGames: [Game.Sapphire],
),
DexEntry(
Game.FireRed,
"A bewitching aroma wafts from its flower. The fragrance becalms those engaged in a battle.",
Generation.Three,
),
DexEntry(
Game.LeafGreen,
"Its plant blooms when it is absorbing solar energy. It stays on the move to seek sunlight.",
Generation.Three,
),
DexEntry(
Game.Emerald,
"VENUSAURs flower is said to take on vivid colors if it gets plenty of nutrition and sunlight. The flowers aroma soothes the emotions of people.",
Generation.Three,
),
],
),
Charmander(4, Generation.One, [Type.Fire], SingleEvolution(5, 16)),
Charmeleon(
@ -351,7 +564,114 @@ enum Pokemon {
previousPokemon: 7,
),
Blastoise(9, Generation.One, [Type.Water], null, previousPokemon: 8),
Caterpie(10, Generation.One, [Type.Bug], SingleEvolution(11, 7)),
Caterpie(
10,
Generation.One,
[Type.Bug],
SingleEvolution(11, 7),
locations: [
Location(Game.Red, [
GameRoute.RT25,
GameRoute.ViridianForest,
], Generation.One),
Location(Game.Blue, [
GameRoute.RT2,
GameRoute.RT24,
GameRoute.RT25,
GameRoute.ViridianForest,
], Generation.One),
Location(Game.Yellow, [GameRoute.ViridianForest], Generation.One),
Location(Game.Gold, [
GameRoute.RT2,
GameRoute.RT26,
GameRoute.RT27,
GameRoute.RT30,
GameRoute.RT31,
GameRoute.RT34,
GameRoute.RT35,
GameRoute.RT36,
GameRoute.RT37,
GameRoute.RT38,
GameRoute.RT39,
GameRoute.AzaleaTown,
GameRoute.IlexForest,
GameRoute.LakeOfRage,
GameRoute.NationalPark,
], Generation.Two),
Location(Game.Silver, [GameRoute.NationalPark], Generation.Two),
Location(Game.Crystal, [
GameRoute.RT2,
GameRoute.RT24,
GameRoute.RT25,
GameRoute.RT30,
GameRoute.RT31,
GameRoute.IlexForest,
GameRoute.NationalPark,
], Generation.Two),
Location(
Game.Ruby,
[GameRoute.TradeOrMigrate],
Generation.Three,
additionalGames: [Game.Sapphire, Game.Emerald],
),
Location(Game.FireRed, [
GameRoute.RT2,
GameRoute.RT24,
GameRoute.RT25,
GameRoute.PatternBush,
GameRoute.ViridianForest,
], Generation.Three),
],
dexEntries: [
DexEntry(
Game.Red,
"Its short feet are tipped with suction pads that enable it to tirelessly climb slopes and walls.",
Generation.One,
additionalGames: [Game.Blue],
),
DexEntry(
Game.Yellow,
"If you touch the feeler on top of its head, it will release a horrible stink to protect itself.",
Generation.One,
),
DexEntry(
Game.Gold,
"For protection, it releases a horrible stench from the antenna on its head to drive away enemies.",
Generation.Two,
),
DexEntry(
Game.Silver,
"Its feet have suction cups designed to stick to any surface. It tenaciously climbs trees to forage.",
Generation.Two,
),
DexEntry(
Game.Crystal,
"It crawls into foliage where it camouflages itself among leaves that are the same color as its body.",
Generation.Two,
),
DexEntry(
Game.Ruby,
"CATERPIE has a voracious appetite. It can devour leaves bigger than its body right before your eyes. From its antenna, this POKéMON releases a terrifically strong odor.",
Generation.Three,
additionalGames: [Game.Sapphire],
),
DexEntry(
Game.FireRed,
"It is covered with a green skin. When it grows, it sheds the skin, covers itself with silk, and becomes a cocoon.",
Generation.Three,
),
DexEntry(
Game.LeafGreen,
"Its short feet are tipped with suction pads that enable it to tirelessly climb slopes and walls.",
Generation.Three,
),
DexEntry(
Game.Emerald,
"Its voracious appetite compels it to devour leaves bigger than itself without hesitation. It releases a terribly strong odor from its antennae.",
Generation.Three,
),
],
),
Metapod(
11,
Generation.One,
@ -1778,6 +2098,8 @@ enum Pokemon {
final int dexID;
final int previousPokemon;
final List<String> extraVariants;
final List<Location> locations;
final List<DexEntry> dexEntries;
bool get hasEvolutions => evolution != null;
const Pokemon(
this.id,
@ -1788,6 +2110,8 @@ enum Pokemon {
this.properName = "",
this.previousPokemon = -1,
this.extraVariants = const [],
this.locations = const [],
this.dexEntries = const [],
});
String get pokemonName => properName == "" ? name : properName;
@ -1809,10 +2133,7 @@ enum Pokemon {
foregroundColor: WidgetStatePropertyAll(type.textColor),
),
child: Text(
type.name,
style: TextStyle(fontSize: Constants.isMobile ? 16 : 32),
),
child: Text(type.name, style: TextStyle(fontSize: 16)),
),
);
}
@ -1841,7 +2162,7 @@ enum Pokemon {
else {
List<Widget> tmpRow = [];
int i = 0;
int row = Constants.isMobile ? 3 : 4;
int row = 3;
for (var variant in extraVariants) {
tmpRow.add(Image.asset("assets/sprites/${variant}.png"));
@ -1909,11 +2230,7 @@ enum Pokemon {
height: 256,
child: Column(
children: [
Image.asset(
toDexPath(),
width: Constants.isMobile ? 64 : 128,
height: Constants.isMobile ? 64 : 128,
),
Image.asset(toDexPath(), width: 64, height: 64),
Text(pokemonName, style: TextStyle(fontSize: 24)),
getTypeWidgets(),
],
@ -1939,4 +2256,79 @@ enum Pokemon {
return sprites;
}
Widget printDescription() {
List<Widget> widgets = [];
for (var descs in dexEntries) {
if (descs.gameGen.idStart > SessionData.highestGenID()) continue;
List<String> gameNames = [descs.game.toString()];
for (var extra in descs.additionalGames) {
gameNames.add(extra.toString());
}
widgets.add(
Card.filled(
elevation: 50,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
"Game: ${gameNames.join(", ")}\nDescription: ${descs.desc}",
),
],
),
),
),
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widgets,
);
}
Widget printLocations() {
List<Widget> widgets = [];
for (var locs in locations) {
if (locs.gameGen.idStart > SessionData.highestGenID()) continue;
List<String> routes = [];
for (var rt in locs.routes) {
routes.add(rt.toString());
}
List<String> gameNames = [locs.game.toString()];
for (var extra in locs.additionalGames) {
gameNames.add(extra.toString());
}
widgets.add(
Card.outlined(
elevation: 50,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
"Game: ${gameNames.join(", ")}\n\nRoutes/Method: ${routes.join(", ")}",
),
],
),
),
),
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widgets,
);
}
}

View file

@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.032525+2026
version: 1.0.032525+2222
environment:
sdk: ^3.7.0