fetchWebUrlsWithGemma method
- String placeName,
- BuildContext context
Fetches a list of URLs related to the specified place name from the Gemma API.
placeName
: The name of the place to search for.
context
: The BuildContext used for localization.
Returns a list of URLs as a List of Strings.
Implementation
Future<List<String>> fetchWebUrlsWithGemma(
String placeName, BuildContext context) async {
final Uri uri = Uri.parse('$baseUrl/search?place_name=$placeName');
final response = await http.get(uri);
if (response.statusCode == 200) {
List<dynamic> jsonList = json.decode(response.body);
return jsonList.cast<String>();
} else {
// throw Exception('Failed to fetch URLs: ${response.reasonPhrase}');
throw Exception(AppLocalizations.of(context)!
.aiGenerationAPIGemma_errorFetchURLs(
response.reasonPhrase.toString()));
}
}