Merge pull request #680 from cake-tech/CW-275-fix-picker-search-issue

Fix Settings Pickers Search
This commit is contained in:
Omar Hatem 2022-12-21 21:04:52 +02:00 committed by GitHub
commit 915b265f69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View file

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:cake_wallet/src/widgets/picker.dart';
import 'package:cake_wallet/src/widgets/standard_list.dart';
class SettingsPickerCell<ItemType extends Object> extends StandardListRow {
class SettingsPickerCell<ItemType> extends StandardListRow {
SettingsPickerCell(
{required String title,
required this.selectedItem,

View file

@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:cake_wallet/src/widgets/alert_background.dart';
import 'package:cake_wallet/src/widgets/alert_close_button.dart';
class Picker<Item extends Object> extends StatefulWidget {
class Picker<Item> extends StatefulWidget {
Picker({
required this.selectedAtIndex,
required this.items,
@ -39,7 +39,7 @@ class Picker<Item extends Object> extends StatefulWidget {
_PickerState<Item> createState() => _PickerState<Item>(items, images, onItemSelected);
}
class _PickerState<Item> extends State<Picker> {
class _PickerState<Item> extends State<Picker<Item>> {
_PickerState(this.items, this.images, this.onItemSelected);
final Function(Item) onItemSelected;
@ -59,7 +59,7 @@ class _PickerState<Item> extends State<Picker> {
images = [];
for (int i=0;i<widget.items.length;i++) {
if (widget.matchingCriteria?.call(widget.items[i], searchController.text) ?? true) {
items.add(widget.items[i] as Item);
items.add(widget.items[i]);
images.add(widget.images[i]);
}
}
@ -238,8 +238,7 @@ class _PickerState<Item> extends State<Picker> {
child: Padding(
padding: EdgeInsets.only(left: image != null ? 12 : 0),
child: Text(
// What a hack (item as) ?
widget.displayItem?.call(item as Object) ?? item.toString(),
widget.displayItem?.call(item) ?? item.toString(),
style: TextStyle(
fontSize: 14,
fontFamily: 'Lato',