0
I’m trying to make my search system work
The entire app is made in Flutter, Mobx for State and Get It for Injection and the data comes from a json API
I’ve tried it in some ways, but I can’t make it work, I’ve run some groups and they told me my code is correct, so they don’t know why it doesn’t work
This is my code:
My @observable
@observable
String buscar = "";
My @action
@action
void setBuscando(String value) => buscar = value;
And my @computed
List get resultadoBusca {
if (buscar.isEmpty) {
return listaOSs;
} else {
return listaOSs.where((element) => element.contains(buscar)).toList();
}
}
And I need to display it on my list, and here’s her code
separatorBuilder: (_, index) => Divider(
height: altura / 22,
),
itemCount: dadosOS.tamanhoListaOSs, //limitador de objetos criados
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
Navigator.pushNamed(
context,
"/detalhada",
arguments: Detalhada(numero: index),
);
},
child: Container(
color: Colors.white.withOpacity(0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"O.S." + dadosOS.listaOSs[index]["id"].toString(),
style: TextStyle(
fontSize: largura / 30,
),
),
My search field is on another page and so on
TextField(
autocorrect: false,
maxLines: 1,
onChanged: osLogin.setBuscando,
textAlignVertical: TextAlignVertical.bottom,
decoration: InputDecoration(
labelText: "Nome, nº ou status",
hintText: "",
prefixIcon: Icon(
Icons.search,
),
),
),