Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onFind on press back button on android display [No data found] #35

Open
fnoceda opened this issue Apr 2, 2021 · 0 comments
Open

onFind on press back button on android display [No data found] #35

fnoceda opened this issue Apr 2, 2021 · 0 comments

Comments

@fnoceda
Copy link

fnoceda commented Apr 2, 2021

HI, i have a problem, i need implemented with a model, al is fine, but when i find on the text searchBox, the result return the list of data but when i press in the phone back button for scrolling mi new list, the results display [No data found]
This is my code

Widget _UserModelDropFind(FormularioController _){

  return Obx((){
      if(_.isPrestadoresPrestaciones.value == true){
        return FindDropdown<UserModel>(
            items: _.prestadoresPrestaciones,
            label: "Prestador *",
            onChanged: (UserModel value) {
                _.setUserModel(value);
            },
            selectedItem: _.UserModel,
            labelStyle: TextStyle(
                color: Colors.grey[600], fontSize: 18, fontWeight: FontWeight.w300),
            searchBoxDecoration: InputDecoration(hintText: "Buscar..."),
            titleStyle: TextStyle(color: Colors.indigo[700].withRed(80)),

            dropdownBuilder: (BuildContext context, UserModel item) {
                print('Se esta ejecutando dropdownBuilder');
                return Container(
                decoration: BoxDecoration(
                    border: Border.all(color: Theme.of(context).dividerColor),
                    borderRadius: BorderRadius.circular(5),
                    color: Colors.white,
                ),
                child: (item == null)
                    ? ListTile(title: Text("Elija al prestador"), dense: true)
                    : ListTile(
                        dense: true,
                        title: Text(item.nomprestador),
                        subtitle: Text(item.nomprestacion),
                        ),
                );
            },
            dropdownItemBuilder: (BuildContext context, UserModel item, bool isSelected) {
                print('Se esta ejecutando dropdownItemBuilder');
                return Container(
                    decoration: !isSelected
                        ? null
                        : BoxDecoration(
                            border: Border.all(color: Theme.of(context).primaryColor),
                            borderRadius: BorderRadius.circular(5),
                            color: Colors.white,
                            ),
                    child: ListTile(
                        selected: isSelected,
                        title: Text(item.nomprestador),
                        subtitle: Text(item.nomprestacion),
                    ),
                );
            },
            onFind: (String filtro) => _findData(filtro, _),
        );
    }
    return Container();
  });

}

Future<List<UserModel>> _findData(String filtro, FormularioController _) async{
    print('se esta ejecutando _findData');
    print(filtro.toUpperCase());
    List<UserModel> data = [];
    // List<UserModel> data = _.prestadoresPrestaciones.where((UserModel item) => item.nomprestador.toUpperCase().contains(filtro.toUpperCase())).toList();

    if (_.prestadoresPrestaciones.any((element) => element.nomprestador.toLowerCase().contains(filtro.toLowerCase()))) {
        data =  _.prestadoresPrestaciones
            .where((element) =>
                element.nomprestador.toLowerCase().contains(filtro.toLowerCase()))
            .toList();

    }
    print( 'data.length =>' + data.length.toString());
    return data;
}

i apreciate your help.

aweiand pushed a commit to aweiand/find_dropdown that referenced this issue May 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant