class _PokedexState extends State<Pokedex> {
@override
Widget construct(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Textual content('Pokédex'),
centerTitle: true,
backgroundColor: Colours.crimson,
main: const Icon(MdiIcons.pokeball),
),
physique: StreamBuilder(
stream: readPokemon(),
builder: (context, snapshot) {
if (snapshot.hasError) {
return const Textual content('Couldnu0027t discover any Pokémon :( ');
} else if (snapshot.hasData) {
ultimate customers = snapshot.information!;
return ListView(
youngsters: customers.map(buildPokemon).toList(),
);
} else {
return const Heart(youngster: CircularProgressIndicator());
}
},
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton.prolonged(
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => const AddPokemonPage()));
},
label: const Textual content('Add Pokémon'),
icon: new Icon(MdiIcons.pokemonGo),
backgroundColor: Colours.crimson,
),
);
}
}
Widget buildPokemon(Pokemon pokemon) => (
Card(
elevation: 4.0,
youngster:Column(
youngsters: [
ListTile(
title: Text(pokemon.name),
subtitle: Text(pokemon.size),
trailing:IconButton(onPressed: (){
showDialog(context: context, builder: (_) => AlertDialog());
DocumentReference docuRef = FirebaseFirestore.instance.collection('Pokemon').doc(pokemon.id);
docuRef.delete();
}, icon: const Icon(Icons.delete))
),
],
),
)
);