dropdown_sheet 0.0.1
dropdown_sheet: ^0.0.1 copied to clipboard
A customizable dropdown sheet widget for Flutter with search functionality and multiple selection support.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:dropdown_sheet/dropdown_sheet.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Dropdown Sheet Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final ValueNotifier<SheetModel?> selectedCountry = ValueNotifier(null);
final ValueNotifier<SheetModel?> selectedCity = ValueNotifier(null);
final ValueNotifier<SheetModel?> selectedLanguage = ValueNotifier(null);
final ValueNotifier<bool> isLoading = ValueNotifier(false);
final List<SheetModel> countries = [
SheetModel(id: '1', name: 'Türkiye'),
SheetModel(id: '2', name: 'Almanya'),
SheetModel(id: '3', name: 'Fransa'),
SheetModel(id: '4', name: 'İtalya'),
SheetModel(id: '5', name: 'İspanya'),
SheetModel(id: '6', name: 'Hollanda'),
SheetModel(id: '7', name: 'Belçika'),
SheetModel(id: '8', name: 'Avusturya'),
SheetModel(id: '9', name: 'İsviçre'),
SheetModel(id: '10', name: 'Polonya'),
];
final List<SheetModel> cities = [
SheetModel(id: '1', name: 'İstanbul'),
SheetModel(id: '2', name: 'Ankara'),
SheetModel(id: '3', name: 'İzmir'),
SheetModel(id: '4', name: 'Bursa'),
SheetModel(id: '5', name: 'Antalya'),
SheetModel(id: '6', name: 'Adana'),
SheetModel(id: '7', name: 'Konya'),
SheetModel(id: '8', name: 'Gaziantep'),
SheetModel(id: '9', name: 'Mersin'),
SheetModel(id: '10', name: 'Diyarbakır'),
];
final List<SheetModel> languages = [
SheetModel(id: '1', name: 'Türkçe'),
SheetModel(id: '2', name: 'İngilizce'),
SheetModel(id: '3', name: 'Almanca'),
SheetModel(id: '4', name: 'Fransızca'),
SheetModel(id: '5', name: 'İspanyolca'),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text('Dropdown Sheet Example'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Dropdown Sheet Examples',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
// Basic Dropdown
DropdownSheet<SheetModel>(
title: 'Ülke Seçiniz',
values: countries,
notifier: selectedCountry,
isRequired: true,
onChanged: () {
print('Seçilen ülke: ${selectedCountry.value?.name}');
},
),
const SizedBox(height: 16),
// Dropdown with Search
DropdownSheet<SheetModel>(
title: 'Şehir Seçiniz',
values: cities,
notifier: selectedCity,
showSearch: true,
onChanged: () {
print('Seçilen şehir: ${selectedCity.value?.name}');
},
),
const SizedBox(height: 16),
// Dropdown with Loading State
DropdownSheet<SheetModel>(
title: 'Dil Seçiniz',
values: languages,
notifier: selectedLanguage,
loadingNotifier: isLoading,
onChanged: () {
print('Seçilen dil: ${selectedLanguage.value?.name}');
},
),
const SizedBox(height: 20),
// Loading Button
ElevatedButton(
onPressed: () {
isLoading.value = true;
Future.delayed(const Duration(seconds: 2), () {
isLoading.value = false;
});
},
child: const Text('Loading Simülasyonu'),
),
const SizedBox(height: 20),
// Selected Values Display
ValueListenableBuilder<SheetModel?>(
valueListenable: selectedCountry,
builder: (context, country, child) {
return ValueListenableBuilder<SheetModel?>(
valueListenable: selectedCity,
builder: (context, city, child) {
return ValueListenableBuilder<SheetModel?>(
valueListenable: selectedLanguage,
builder: (context, language, child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Seçilen Değerler:',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
Text('Ülke: ${country?.name ?? 'Seçilmedi'}'),
Text('Şehir: ${city?.name ?? 'Seçilmedi'}'),
Text('Dil: ${language?.name ?? 'Seçilmedi'}'),
],
);
},
);
},
);
},
),
],
),
),
);
}
}