💻
Flutter documentation
  • Flutter documentation
    • Starting an App
    • Import
  • Visual Studio Code
  • Widgets
    • Stateless Widget
    • Stateful Widget
    • Scaffold
    • Text
      • OverFlow
      • Rounded background text
    • Padding
    • Align
    • DraggableScrollableSheet
    • Container
    • Decorated box
    • Expanded
    • IntrinsicHeight
    • IntrinsicWidth
    • ListView.builder(...)
    • Buttons
    • Gauge
    • Navigator
      • WillPopScope
    • Web View
    • Divider
    • Future builder
    • Image
      • Cached_network_image
      • Fade In Image
    • ClipOval
    • InkWell
    • Wrap
    • SingleChildScrollView
    • Stack
    • FittedBox
    • DropdownButton
    • ValueListenableBuilder
    • Maps
    • fl_chart
    • Set SystemNavigation Bar Color
    • Onesignal
    • Builder
    • Set orientation
    • SSE
    • Chat
    • Flutter_animate
    • Supabase
      • Android
    • Changing name and package name
    • Sign apk/abb
  • Dart
    • If / Else in one line
    • Functions
  • Others
  • Airtable
Powered by GitBook
On this page
  1. Widgets

DropdownButton

A DropdownButton is a widget in Flutter that allows users to select an option from a dropdown menu.

ValueListenableBuilder(
            //create a valueListenable to be updated when choosing a language
            valueListenable: _listenable,
            builder: (context, value, child) {
              //create the language drop down menu
              return DropdownButton<String>(
                dropdownColor: Color.fromARGB(255, 47, 191, 164),
                //the initial value as the Language variable
                value: Idioma,
                //when it changes
                onChanged: (newValue) {
                  //change the Language variable
                  Idioma = newValue.toString();
                  //change the _listenable variable so that it is updated
                  _listenable.value++;
                },
                // for each item in the list _languages we create a DropdownmenuItem
                items: _idiomas.map((idioma) {
                  return DropdownMenuItem<String>(
                    //value is language
                    value: idioma,
                    //the content is a text with the language
                    child: Text(
                      idioma,
                      style: TextStyle(color: Colors.white),
                    ),
                  );
                }).toList(),
              );
            })
PreviousFittedBoxNextValueListenableBuilder

Last updated 2 years ago