Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:saltita/src/models/genre_model.dart';
- import 'package:saltita/src/providers/api_provider.dart';
- class CreateBand extends StatefulWidget {
- const CreateBand({super.key});
- @override
- State<CreateBand> createState() => _CreateBandState();
- }
- class _CreateBandState extends State<CreateBand> {
- ApiConn api = ApiConn();
- final List<GenreResult> _genre = [];
- void addGenre (GenreResult items){
- _genre.add(items);
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: const Text('Registra tu Banda'),
- ),
- body: FutureBuilder(
- future: api.getGenres(),
- builder:(context, snapshot) {
- if (snapshot.hasData) {
- snapshot.data.map((e) => addGenre(GenreResult.fromJson(e.data))).toList();
- return Container(
- padding: const EdgeInsets.all(10),
- margin: const EdgeInsets.all(10),
- child: SingleChildScrollView(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- TextFormField(
- decoration: const InputDecoration(
- hintText: 'Nombre de la Banda',
- labelText: 'Nombre',
- ),
- ),
- TextFormField(
- decoration: const InputDecoration(
- hintText: 'DescripciĆ³n de la Banda',
- labelText: 'DescripciĆ³n',
- ),
- ),
- DropdownButtonFormField(
- items: _genre.map((e) => DropdownMenuItem(
- value: e.nombre,
- child: Text(e.nombre),
- )).toList(),
- onChanged: (e){}
- ),
- ElevatedButton(onPressed: (){}, child: const Text('Registrar Banda'))
- ]
- ),
- ),
- ) ;
- } else {
- return const Center(child: CircularProgressIndicator());
- }
- },
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement