in ,

Flutter package designed to select an item from a list

select_dialog Package

To select a random item from your list, this Package was developed to do just that. Furthermore, it’s ready to help you with the option filter and even look up the items on the internet.

package

pubspec.yaml

select_dialog: <last version>

import

import 'package:select_dialog/select_dialog.dart';

simple example

String ex1 = "No value selected";

SelectDialog.showModal<String>(
  context,
  label: "Simple Example",
  selectedValue: ex1,
  items: List.generate(50, (index) => "Item $index"),
  onChange: (String selected) {
    setState(() {
      ex1 = selected;
    });
  },
);

Attention

You must implement String, equals, and hashcode, as shown below in order to use a template as an item type:

class UserModel {
  final String id;
  final DateTime createdAt;
  final String name;
  final String avatar;

  UserModel({this.id, this.createdAt, this.name, this.avatar});

  @override
  String toString() => name;

  @override
  operator ==(o) => o is UserModel && o.id == id;

  @override
  int get hashCode => id.hashCode^name.hashCode^createdAt.hashCode;

}

GitHub

https://github.com/davidsdearaujo/select_dialog

Written by James

A flutter Package to show custom alert Dialog

A semantic way to fill the content inside the dialog