Reputation: 5207
I want to make autocomplete for entering location data (cities)... So I have a TextField
where users enter city name and I'm trying to make a Box below that TextField
with suggestions from API in JSON format.
onChanged: (t) {
setState(() {
return Container(
decoration:
BoxDecoration(border: Border.all(color: Colors.black)),
child: ListView.builder(
itemBuilder: (BuildContext ctxt, int Index) {
return new Text(litems[Index]);
}));
});
},
But the problem is I don't see any box container and I get no errors in logs. What could be the reason why this box is not rendering?
Upvotes: 2
Views: 1063
Reputation: 268334
You'll need to create the box in your build()
method. And initially you can hide it using Visibility
widget. And whenever you want to show it you can make _visible = true
.
I'm just giving you the idea to solve your problem since you didn't share any code.
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
YourTextFormField(),
Visibility(
visible: _visible,
child: YourBox(),
),
// other children
],
);
}
Upvotes: 1