Skip to content

Commit

Permalink
chore(deps): update dependency dropdown_search to v6 (#424)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency dropdown_search to v6

* fix: 使用最新的写法

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: uy_sun <hmy0119@gmail.com>
  • Loading branch information
renovate[bot] and he0119 authored Dec 4, 2024
1 parent 2f64c38 commit b67205c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/storage/view/consumable_edit_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class _ConsumableEditPageState extends State<ConsumableEditPage> {
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
child: MyDropdownSearch(
label: '耗材',
asyncItems: (text) async {
items: (text, loadProps) async {
final items =
await RepositoryProvider.of<StorageRepository>(context)
.items(key: text, cache: false);
Expand Down
21 changes: 11 additions & 10 deletions lib/widgets/dropdown_search.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'package:dropdown_search/dropdown_search.dart';
import 'package:flutter/material.dart';

typedef DropdownSearchOnFind<T> = Future<List<T>> Function(String? text);

class MyDropdownSearch<T> extends StatelessWidget {
final String? label;
final DropdownSearchOnFind<T>? asyncItems;
final DropdownSearchOnFind<T>? items;
final ValueChanged<T?>? onChanged;
final T? selectedItem;
final bool showClearButton;
Expand All @@ -15,7 +13,7 @@ class MyDropdownSearch<T> extends StatelessWidget {
const MyDropdownSearch({
super.key,
this.label,
this.asyncItems,
this.items,
this.onChanged,
this.selectedItem,
this.showClearButton = false,
Expand All @@ -28,10 +26,11 @@ class MyDropdownSearch<T> extends StatelessWidget {
return DropdownSearch<T>(
compareFn: (i1, i2) => i1 == i2,
popupProps: PopupProps.menu(
isFilterOnline: true,
disableFilter: true,
showSelectedItems: true,
showSearchBox: true,
itemBuilder: (ctx, item, isSelected) {
itemBuilder:
(BuildContext context, T item, bool isDisabled, bool isSelected) {
return ListTile(
title: Text(item.toString()),
selected: isSelected,
Expand All @@ -47,14 +46,16 @@ class MyDropdownSearch<T> extends StatelessWidget {
),
),
),
dropdownDecoratorProps: DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
decoratorProps: DropDownDecoratorProps(
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
labelText: label,
),
),
clearButtonProps: const ClearButtonProps(isVisible: true),
asyncItems: asyncItems,
suffixProps: DropdownSuffixProps(
clearButtonProps: const ClearButtonProps(isVisible: true),
),
items: items,
onChanged: onChanged,
selectedItem: selectedItem,
validator: validator,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ packages:
dependency: "direct main"
description:
name: dropdown_search
sha256: "55106e8290acaa97ed15bea1fdad82c3cf0c248dd410e651f5a8ac6870f783ab"
sha256: "8c96aaf8d0c0d4307804b28da73866e5a0fc94fd8e6942eceab896450aaa4999"
url: "https://pub.dev"
source: hosted
version: "5.0.6"
version: "6.0.1"
dynamic_color:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies:
datetime_picker_formfield: ^2.0.1
flutter_markdown_selectionarea: ^0.6.17+1
cached_network_image: ^3.4.1
dropdown_search: ^5.0.6
dropdown_search: ^6.0.1
flutter_sticky_header: ^0.6.5
extended_sliver: ^2.1.3

Expand Down

0 comments on commit b67205c

Please sign in to comment.