🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / FLUTTER / Yeni Searchable Dropdown Aranabilir Combobox kullanımı search_choices

1-) FLUTTER - Yeni Searchable Dropdown Aranabilir Combobox kullanımı search_choices

 

1

 

flutter pub add search_choices

 

 

 

import 'package:flutter/material.dart';
import 'package:search_choices/search_choices.dart';

class DropDownIlce extends StatefulWidget {
  
const DropDownIlce({super.key});

  
@override
  
State<DropDownIlce> createState() => _DropDownIlceState();
}

class _DropDownIlceState extends State<DropDownIlce> {
  
// Define a list of cities for the dropdown menu
  
final List<String> cities = ['Antalya', 'Istanbul', 'Ankara'];

  
// Variable to store the selected value
  
String selectedCity = 'İl Seçiniz';

  
@override
  
Widget build(BuildContext context) {
    
return SearchChoices.single(
      items:
cities
          
.map((city) => DropdownMenuItem<String>(
        value: city,
        child:
Text(city),
      ))
          .toList(),
      value:
selectedCity,
      hint:
"İl Seçiniz",
      searchHint:
"İl Seçiniz",
      onChanged: (value) {
        setState(() {
          
selectedCity = value;
        });
      },
      isExpanded:
true,
      padding:
EdgeInsets.all(5),

    );
  }
}

 

 

 

 2024 Haziran 04 Salı
 259