I tried to used google map autocomplete, but I got the this error LateInitializationError: Field 'searchResults' has not been initialized.
How can solve it problem?
I still tried to used this way, but still falue.
void initState() {
searchResults;
}
This is my code
late List<PlaceSearch> searchResults;
final placeService = PlaceSerive();
searchPlaces(String searchTerm) async {
searchResults = await placeService.getAutoComplete(searchTerm);
}
...
...
void initState() {
searchResults;
}
...
...
...
child: ListView.builder(
itemCount: searchResults.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(searchResults[index].description,
style: TextStyle(color: Colors.black)),
);
},
),