mirror of
https://github.com/chenasraf/pokedex_flutter.git
synced 2026-05-17 17:48:04 +00:00
27 lines
714 B
Dart
27 lines
714 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:pokedex/data/pokemon.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../core/models/pokemon.dart';
|
|
|
|
class PokemonListController extends ChangeNotifier {
|
|
bool loading = false;
|
|
Iterable<Pokemon> pokemonList = [];
|
|
|
|
PokemonListController() {
|
|
debugPrint('PokemonListController()');
|
|
getPokemon();
|
|
}
|
|
|
|
static PokemonListController of(BuildContext context) =>
|
|
Provider.of<PokemonListController>(context, listen: false);
|
|
|
|
Future<void> getPokemon() async {
|
|
debugPrint('getPokemon()');
|
|
loading = true;
|
|
await Future.microtask(() => pokemonList = getAllPokemon().values);
|
|
loading = false;
|
|
notifyListeners();
|
|
}
|
|
}
|