list_item_selector 1.0.1
list_item_selector: ^1.0.1 copied to clipboard
A Flutter package that provides a customizable dropdown selector with dynamic list of data.
example/list_item_selector_example.dart
import 'package:flutter/material.dart';
import 'package:list_item_selector/list_item_selector.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'DropDownSelector Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String? _selectedValue;
final List<String> _options = [
'Option 1',
'Option 2',
'Option 3',
'Option 4',
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('DropDownSelector Demo'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ListItemSelector(
width: 290,
height: 50,
iconSize: 24,
selectedValue: _selectedValue,
items: _options,
hintText: 'Select an option',
onChanged: (newValue) {
setState(() {
_selectedValue = newValue;
});
},
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please select an option';
}
return null;
},
borderColor: Colors.grey,
focusedBorderColor: Colors.blue,
fontSize: 16.0,
hintColor: Colors.grey.shade600,
labelColor: Colors.blue.shade800,
borderRadius: 12.0,
contentPadding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
),
],
),
),
);
}
}