dropdown_model_list 1.1.7 copy "dropdown_model_list: ^1.1.7" to clipboard
dropdown_model_list: ^1.1.7 copied to clipboard

Flexible DropDown Model List works with a simple model list and Easy to use & customized.

example/lib/main.dart

import 'package:dropdown_model_list/dropdown_model_list.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DropDown Menu',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'DropDown Menu'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  DropListModel dropListModel = DropListModel([
    OptionItem(id: "1", title: "Jatin Sharma"),
    OptionItem(id: "2", title: "Puneet Chand"),
    OptionItem(id: "3", title: "Vikas Bhardwaj"),
    OptionItem(id: "4", title: "Rakesh Kumar"),
    OptionItem(id: "5", title: "Alok Dubey"),
    OptionItem(id: "6", title: "Kiran Yadav"),
    OptionItem(id: "7", title: "Pradeep Kumar"),
    OptionItem(id: "8", title: "Amit Kumar"),
    OptionItem(id: "9", title: "Sweta Sharma"),
    OptionItem(id: "10", title: "Ankit Bhist"),
  ]);
  OptionItem optionItemSelected = OptionItem(title: "Select User");

  TextEditingController controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.only(top: 20),
        child: Column(
          children: <Widget>[
            ///Simple DropDown
            SelectDropList(
              itemSelected: optionItemSelected,
              dropListModel: dropListModel,
              showIcon: false,
              showArrowIcon: true,
              showBorder: true,
              paddingTop: 0,
              paddingDropItem: const EdgeInsets.only(
                  left: 20, top: 10, bottom: 10, right: 20),
              suffixIcon: Icons.arrow_drop_down,
              containerPadding: const EdgeInsets.all(10),
              icon: const Icon(Icons.person, color: Colors.black),
              onOptionSelected: (optionItem) {
                optionItemSelected = optionItem;
                setState(() {});
              },
            ),

            ///Search DropDown
            SearchDropList(
              itemSelected: optionItemSelected,
              dropListModel: dropListModel,
              showIcon: false,
              showArrowIcon: true,
              showBorder: true,
              textEditingController: controller,
              paddingTop: 0,
              suffixIcon: Icons.arrow_drop_down,
              containerPadding: const EdgeInsets.all(10),
              icon: const Icon(Icons.person, color: Colors.black),
              onOptionSelected: (optionItem) {
                optionItemSelected = optionItem;
                if (kDebugMode) {
                  print(optionItemSelected.id);
                }
                setState(() {});
              },
            ),

            ///Multiple Selection DropDown
            SelectDropMultipleList(
              defaultText: optionItemSelected,
              dropListModel: dropListModel,
              showIcon: false,
              showBorder: true,
              paddingTop: 0,
              submitText: "OK",
              colorSubmitButton: Colors.amber,
              selectedIconWidget: Container(
                decoration: const BoxDecoration(
                    shape: BoxShape.rectangle, color: Colors.amber),
                child: const Icon(
                  Icons.done,
                  size: 15,
                  color: Colors.white,
                ),
              ),
              suffixIcon: Icons.arrow_drop_down,
              containerPadding: const EdgeInsets.all(10),
              icon: const Icon(Icons.person, color: Colors.black),
              onOptionListSelected: (list) {
                for (var data in list) {
                  if (data.id != null) {
                    if (kDebugMode) {
                      print(data.id);
                    }
                  }
                }
                setState(() {});
              },
            ),

            ///Radio Selection DropDown
            SelectDropRadio(
              defaultText: optionItemSelected,
              dropListModel: dropListModel,
              showIcon: false,
              showBorder: true,
              paddingTop: 0,
              submitText: "OK",
              colorSubmitButton: Colors.amber,
              selectedRadioColor: Colors.amber,
              suffixIcon: Icons.arrow_drop_down,
              containerPadding: const EdgeInsets.all(10),
              icon: const Icon(Icons.person, color: Colors.black),
              onOptionListSelected: (list) {
                for (var data in list) {
                  if (data.id != null) {
                    if (kDebugMode) {
                      print(data.id);
                    }
                  }
                }
                setState(() {});
              },
            ),
          ],
        ),
      ),
    );
  }
}
38
likes
150
pub points
90%
popularity

Publisher

unverified uploader

Flexible DropDown Model List works with a simple model list and Easy to use & customized.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on dropdown_model_list