Add a handler for the filters on evolutions.
This commit is contained in:
parent
3f4462435b
commit
670c23d264
6 changed files with 94 additions and 52 deletions
|
@ -1,6 +1,39 @@
|
|||
import 'package:pokedex/filters.dart';
|
||||
import 'package:pokedex/pokemon.dart';
|
||||
|
||||
class SessionData {
|
||||
static bool darkMode = false;
|
||||
static int filter = Filters.All;
|
||||
static int highest = 9;
|
||||
static int _cachedHighest = -1;
|
||||
|
||||
static void resetHighestGenCache() {
|
||||
_cachedHighest = -1;
|
||||
}
|
||||
|
||||
static int highestGenID() {
|
||||
if (_cachedHighest != -1) return _cachedHighest;
|
||||
List<Generation> gens = [];
|
||||
|
||||
if (highest >= 9) gens.add(Generation.Nine);
|
||||
if (highest >= 8) gens.add(Generation.Eight);
|
||||
if (highest >= 7) gens.add(Generation.Seven);
|
||||
if (highest >= 6) gens.add(Generation.Six);
|
||||
if (highest >= 5) gens.add(Generation.Five);
|
||||
if (highest >= 4) gens.add(Generation.Four);
|
||||
if (highest >= 3) gens.add(Generation.Three);
|
||||
if (highest >= 2) gens.add(Generation.Two);
|
||||
if (highest >= 1) gens.add(Generation.One);
|
||||
|
||||
int max = 0;
|
||||
// Iterate over the list, and get the count of all pokemon from a specific generation
|
||||
for (var gen in gens) {
|
||||
for (var pokemon in Pokemon.values) {
|
||||
if (pokemon.generation == gen) max++;
|
||||
}
|
||||
}
|
||||
|
||||
_cachedHighest = max;
|
||||
|
||||
return max;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue