Get data from FirebaseDatabase to dropdown in Flutter

Viewed 25

DB Structure

This is an example of my Firebase Database. How can I create a dropdown for registration page where I can load the Region from "address_lookup"?

  @override
  Widget build(BuildContext context) {
    return Container(
      child: DropdownButton(
          value: selectedType,
          isExpanded: false,
          hint: const Text(
            "Select Region ex. Region IV-A (CALABARZON)",
          ),
          icon: const Icon(Icons.arrow_downward),
          elevation: 10,
          items: _addressLocation
              //             items: users.map((User user) {
              .map((dynamic value) => DropdownMenuItem(
                    value: value,
                    child: Text(
                      value,
                      style: const TextStyle(fontWeight: FontWeight.bold),
                    ),
                  ))
              .toList(),
          onChanged: (newmenu) {
            setState(() {
              selectedType = _addressLocation;
            });
          }),
    );
  }
0 Answers
Related