패키지, 저장소 및 앱 카테고리 검색

find_dropdown 표지
패키지 상세v1.0.0

find_dropdown

아이템 검색 기능을 갖춘 간단하고 견고한 FindDropdown로 오프라인 항목 목록 또는 필터링 URL을 사용하여 쉽게 맞춤설정할 수 있습니다.

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 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.