パッケージ、リポジトリ、アプリカテゴリを検索

find_dropdown のカバー
パッケージ詳細v1.0.0

find_dropdown

アイテム検索機能を備えたシンプルで堅牢な FindDropdown で、オフラインのアイテムリストまたはフィルターリンクを使用して簡単にカスタマイズできます。

30日間ダウンロード
143
いいね数
82
Pub ポイント
70

パッケージをインストール

flutter pub add find_dropdown

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

FindDropdown は、軽量で信頼性の高い Flutter パッケージであり、ユーザーがオフラインリストまたはリモートURLからアイテムをフィルタリングできる検索可能なドロップダウンウィジェットを提供します。カスタマイズ可能な検索動作をサポートし、フォームや選択インターフェースにスムーズに統合できます。シンプルさとパフォーマンスを重視して設計されており、最小限のセットアップで滑らかなユーザーエクスペリエンスを提供します。リアルタイムフィルタリングを伴う効率的なアイテム選択が必要なアプリケーションに最適です。

用途

  • 検索可能なオプションを備えたフォーム入力
  • オフラインデータ選択
  • URLからの動的フィルタリング
  • 使いやすいドロップダウンメニュー
  • カスタマイズ可能な検索ロジック

主な機能

  • リアルタイム検索機能
  • オフラインおよびオンラインのデータソースをサポートします
  • UIおよび動作の簡単なカスタマイズ
  • 軽量でパフォーマンスに優れる
  • 検索効率のための組み込みデバウンス

適している対象

  • 大規模なオプションリストを持つフォームを構築している開発者
  • 高速で応答性の高いドロップダウンが必要なアプリ
  • オフライン優先の設計を必要とするプロジェクト
  • シンプルな統合を重視するチーム

注意事項

  • 非同期データ取得の手動処理が必要
  • 制限された組み込みスタイルオプション
  • 複雑なネストされたデータのネイティブサポートなし
  • エッジケースに対する追加の検証が必要になる可能性があります
  • ページネーションなしの非常に大きなデータセットに対して最適化されていない

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Buy Me A Coffee

FindDropdown package - [ver em português]

Simple and robust FindDropdown with item search feature, making it possible to use an offline item list or filtering URL for easy customization.

ATTENTION

If you use rxdart in your project in a version lower than 0.23.x, use version 0.1.7+1 of this package. Otherwise, you can use the most current version!

Versions

Null Safety Version: 1.0.0 or more

Non Null Safety Version: 0.2.3 or less

RxDart 0.23.x or less: 0.1.7+1

packages.yaml

find_dropdown: <lastest version>

Import

import 'package:find_dropdown/find_dropdown.dart';

Simple implementation

FindDropdown(
  items: ["Brasil", "Itália", "Estados Unidos", "Canadá"],
  label: "País",
  onChanged: (String item) => print(item),
  selectedItem: "Brasil",
);

Multiple selectable items

FindDropdown<String>.multiSelect(
  items: ["Brasil", "Itália", "Estados Unidos", "Canadá"],
  label: "País",
  onChanged: (List<String> items) => print(items),
  selectedItems: ["Brasil"],
);

Validation

FindDropdown(
  items: ["Brasil", "Itália", "Estados Unidos", "Canadá"],
  label: "País",
  onChanged: (String item) => print(item),
  selectedItem: "Brasil",
  validate: (String item) {
    if (item == null)
      return "Required field";
    else if (item == "Brasil")
      return "Invalid item";
    else
      return null; //return null to "no error"
  },
);

Endpoint implementation (using Dio package)

FindDropdown<UserModel>(
  label: "Nome",
  onFind: (String filter) async {
    var response = await Dio().get(
        "http://5d85ccfb1e61af001471bf60.mockapi.io/user",
        queryParameters: {"filter": filter},
    );
    var models = UserModel.fromJsonList(response.data);
    return models;
  },
  onChanged: (UserModel data) {
    print(data);
  },
);

Clear selected items

var countriesKey = GlobalKey<FindDropdownState>();

Column(
  children: [
    FindDropdown<String>(
      key: countriesKey,
      items: ["Brasil", "Itália", "Estados Unidos", "Canadá"],
      label: "País",
      selectedItem: "Brasil",
      showSearchBox: false,
      onChanged: (selectedItem) => print("country: $selectedItem"),
    ),
    RaisedButton(
      child: Text('Limpar Países'),
      color: Theme.of(context).primaryColor,
      textColor: Theme.of(context).primaryIconTheme.color,
      onPressed: () => countriesKey.currentState?.clear(),
    ),
  ],
)

Change selected items

var countriesKey = GlobalKey<FindDropdownState>();

Column(
  children: [
    FindDropdown<UserModel>(
      label: "Nome",
      onFind: (String filter) => getData(filter),
      searchBoxDecoration: InputDecoration(
        hintText: "Search",
        border: OutlineInputBorder(),
      ),
      onChanged: (UserModel data) {
        print(data);
        countriesKey.currentState.setSelectedItem("Brasil");
      },
    ),
    FindDropdown<String>(
      key: countriesKey,
      items: ["Brasil", "Itália", "Estados Unidos", "Canadá"],
      label: "País",
      selectedItem: "Brasil",
      showSearchBox: false,
      onChanged: (selectedItem) => print("country: $selectedItem"),
    ),
  ],
)
MORE EXAMPLES

Layout customization

You can customize the layout of the FindDropdown and its items. EXAMPLE

To customize the FindDropdown, we have the dropdownBuilder property, which takes a function with the parameters:

  • BuildContext context: current context;
  • T item: Current item, where T is the type passed in the FindDropdown constructor.

To customize the items, we have the dropdownItemBuilder property, which takes a function with the parameters:

  • BuildContext context: current context;
  • T item: Current item, where T is the type passed in the FindDropdown constructor.
  • bool isSelected: Boolean that tells you if the current item is selected.

Attention

To use a template as an item type, you need to implement toString, equals and hashcode, as shown below:

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;

}

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。