You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, can you help me with a question? I have an array where I select a city and save the data in a database, but when I try to modify the city, the previously saved city is not loading correctly. I’m not sure if flutter_typeahead can handle this.
TypeAheadField(
//renderiza el texto para que se muestre al momento de seleccionar la ciudad del array
controller: cityController,
builder: ( BuildContext context, controller, FocusNode focusNode) {
return TextField(
controller: controller,
focusNode: focusNode,
obscureText: false,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color:colors.primary, width: 2.0)
),
fillColor: Colors.white,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8)
),
labelText: 'Buscar y seleccionar ciudad.'
),
);
},
suggestionsCallback: (pattern) async {
final Completer<List<City>> completer = Completer();
// Cancelar el timer anterior si existe
if(_debounce?.isActive ?? false) _debounce!.cancel();
// Crear un nuevo timer
_debounce = Timer(const Duration(milliseconds: 500), () async {
await cityProvider.getCity(limit: 10, page: 1, search: pattern);
final filterCity = cityProvider.city.where((city) =>
city.nameCity.toLowerCase().contains(pattern.toLowerCase())
).toList();
completer.complete(filterCity);
});
return completer.future;
},
itemBuilder: (context, City suggestion){
return ListTile(
title: Text(suggestion.nameCity),
);
},
onSelected: (City suggestion){
//actualizar el estado con la seleccion seleccionada
setState(() {
selectCity = suggestion.nameCity;
cityId = suggestion.id ;
cityController.text = suggestion.nameCity;
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('La ciudad seleccionada fue ${suggestion.nameCity}'))
);
print('seleccion ${suggestion.id}');
},
The text was updated successfully, but these errors were encountered:
Hello, can you help me with a question? I have an array where I select a city and save the data in a database, but when I try to modify the city, the previously saved city is not loading correctly. I’m not sure if flutter_typeahead can handle this.
TypeAheadField(
//renderiza el texto para que se muestre al momento de seleccionar la ciudad del array
controller: cityController,
builder: ( BuildContext context, controller, FocusNode focusNode) {
The text was updated successfully, but these errors were encountered: