Home > Net >  I want to put my listview inside a dropdownbottom
I want to put my listview inside a dropdownbottom

Time:12-01

This data is coming from an API and I would like to put all options inside the dropdown

enter image description here

can anybody help me? I'm new to flutter and I'm still learning to use

this is my code:

class _ApiFipePageState extends State<ApiFipePage>{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: FutureBuilder<dynamic>(
        future: pegarUsuarios(),
        builder: (context, snapshot) {
          if (snapshot.hasData) {
            return ListView.builder(
                itemCount: snapshot.data!.length,
                itemBuilder: (context, index) {
                  var usuario = snapshot.data![index];
                  return ListTile(
                    title: Text(usuario['nome']),
                  );
                });
          } else if (snapshot.hasError) {
            return Center(
              child: Text('${snapshot.error}'),
            );
          }
          return Center(
            child: CircularProgressIndicator(),
          );
        },
      ),
    );
  }

  pegarUsuarios() async {
    var url = Uri.parse('https://parallelum.com.br/fipe/api/v1/carros/marcas');
    var resposta = await http.get(url);
    if (resposta.statusCode == 200) {
      return jsonDecode(resposta.body);
    } else {
      throw Exception('não foi possivel carregar os usuarios');
    }
  }

CodePudding user response:

Try below answer hope its help to you. you can refer my answer enter image description here

Your result Screen for Dropdown -> img

  • Related