Advertisement
SoloNadveos

Untitled

Feb 22nd, 2023
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.42 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:saltita/src/models/genre_model.dart';
  3. import 'package:saltita/src/providers/api_provider.dart';
  4.  
  5. class CreateBand extends StatefulWidget {
  6.   const CreateBand({super.key});
  7.  
  8.   @override
  9.   State<CreateBand> createState() => _CreateBandState();
  10. }
  11.  
  12. class _CreateBandState extends State<CreateBand> {
  13.   ApiConn api = ApiConn();
  14.   final List<GenreResult> _genre = [];
  15.  
  16.  
  17.   void addGenre (GenreResult items){
  18.     _genre.add(items);
  19.   }
  20.  
  21.  
  22.   @override
  23.   Widget build(BuildContext context) {
  24.  
  25.    
  26.     return  Scaffold(
  27.       appBar: AppBar(
  28.         title: const Text('Registra tu Banda'),
  29.        
  30.       ),
  31.       body: FutureBuilder(
  32.  
  33.         future: api.getGenres(),
  34.         builder:(context, snapshot) {
  35.           if (snapshot.hasData) {
  36.             snapshot.data.map((e) => addGenre(GenreResult.fromJson(e.data))).toList();
  37.             return Container(
  38.               padding: const EdgeInsets.all(10),
  39.               margin: const EdgeInsets.all(10),
  40.               child: SingleChildScrollView(
  41.            
  42.                 child: Column(
  43.                   mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  44.                   crossAxisAlignment: CrossAxisAlignment.center,
  45.                   mainAxisSize: MainAxisSize.min,
  46.                   children: [
  47.                     TextFormField(
  48.                       decoration: const InputDecoration(
  49.                         hintText: 'Nombre de la Banda',
  50.                         labelText: 'Nombre',
  51.                       ),
  52.                     ),
  53.                     TextFormField(
  54.                       decoration: const InputDecoration(
  55.                         hintText: 'DescripciĆ³n de la Banda',
  56.                         labelText: 'DescripciĆ³n',
  57.                       ),
  58.                     ),
  59.                     DropdownButtonFormField(
  60.                       items:  _genre.map((e) => DropdownMenuItem(
  61.                         value: e.nombre,
  62.                         child: Text(e.nombre),
  63.                       )).toList(),
  64.                       onChanged: (e){}
  65.                       ),
  66.                       ElevatedButton(onPressed: (){}, child: const Text('Registrar Banda'))
  67.                   ]
  68.                 ),
  69.               ),
  70.             ) ;
  71.           } else {
  72.             return const Center(child: CircularProgressIndicator());
  73.           }
  74.         },
  75.       ),
  76.     );
  77.   }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement