搜索插件、代码仓与 APP 分类

GitHub 代码仓mdikcinar/searchable_dropdown

可搜索的下拉菜单

可用于分页请求的 Flutter 可搜索下拉选择框组件。

可搜索的下拉菜单 项目封面
星标
6
复刻
35
最近推送(UTC)
2024年5月5日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

This Flutter package helps create a dropdown which constains a search bar inside. And also provides a feature for compatibility with paginated searchable requests.

Features

  • SearchableDropdown for pre setted item list,
  • SearchableDropdown.paginated for paginated requests.
  • SearchableDropdown.future for normal requests.
  • SearchableDropdownFormfield for compatibility with forms.

Getting started

To use this package, add searchable_dropdown as a dependency in your [pubspec.yaml] file. And add this import to your file.

import 'package:searchable_dropdown/searchable_dropdown.dart';

Usage

Pre setted item list example

SearchableDropdown<int>(
    hintText: const Text('List of items'),
    margin: const EdgeInsets.all(15),
    items: List.generate(10, (i) => SearchableDropdownMenuItem(value: i, label: 'item $i', child: Text('item $i'))),
    onChanged: (int? value) {
        debugPrint('$value');
    },
)

Paginated request example

  • requestItemCount: Paginated request item count which returns in one page, this value is using for knowledge about isDropdown has more item or not.
SearchableDropdown<int>.paginated(
    hintText: const Text('Paginated request'),
    margin: const EdgeInsets.all(15),
    paginatedRequest: (int page, String? searchKey) async {
        final paginatedList = await getAnimeList(page: page, key: searchKey);
        return paginatedList?.animeList
            ?.map((e) => SearchableDropdownMenuItem(value: e.malId, label: e.title ?? '', child: Text(e.title ?? '')))
            .toList();
    },
    requestItemCount: 25,
    onChanged: (int? value) {
        debugPrint('$value');
    },
)

Future request example

SearchableDropdown<int>.future(
    hintText: const Text('Future request'),
    margin: const EdgeInsets.all(15),
    futureRequest: () async {
        final paginatedList = await getAnimeList(page: 1, key: '');
        return paginatedList?.animeList
            ?.map((e) => SearchableDropdownMenuItem(value: e.malId, label: e.title ?? '', child: Text(e.title ?? '')))
            .toList();
    },
    onChanged: (int? value) {
        debugPrint('$value');
    },
)

Example of usage inside a form.

  • backgroundDecoration: Background decoration of dropdown, i.e. with this you can wrap dropdown with Card
Form(
    key: formKey,
    child: SearchableDropdownFormField<int>(
        backgroundDecoration: (child) => Card(
            margin: EdgeInsets.zero,
            color: Colors.red,
            elevation: 3,
            child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: child,
            ),
        ),
        hintText: const Text('Search Anime'),
        margin: const EdgeInsets.all(15),
        items: List.generate(10, (i) => SearchableDropdownMenuItem(value: i, label: 'item $i', child: Text('item $i'))),
        validator: (val) {
            if (val == null) return 'Cant be empty';
            return null;
        },
        onSaved: (val) {
            debugPrint('On save: $val');
        },
    ),
)

License

License

Mustafa Ali Dikçinar GitHub avatar
GitHub 作者

Mustafa Ali Dikçinar ↗

Software developer - Mechatronics engineer

Aydin,Turkey官方网站 ↗
语言DartC++CMakeRubyHTMLCSwiftKotlinObjective-C

分类

此仓库发布的插件

使用的依赖

依赖清单 4 项

  • async>=2.8.2 <3.0.0
  • flutter{"sdk":"flutter"}
  • better_linter开发依赖{"git":{"url":"git@github.com:mdikcinar/better_linter.git","ref":"master"}}
  • flutter_test开发依赖{"sdk":"flutter"}

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗