Flutter Http line not getting executed

0 votes

When I am trying to print the url it is getting printed. but http statement and lines after it are not getting executed.

  print('https://maps.googleapis.com/maps/api/place/autocomplete/json?'
      'input=$cityName&location=${position.latitude},${position.longitude}&radius=50000&language=en&components=country:in&key=$kGoogleApiKey');

  // Url is getting printed
  // but next line is not getting executed.
  http.Response response = await http.get(
    Uri.parse('https://maps.googleapis.com/maps/api/place/autocomplete/json?'
        'input=$cityName&location=${position.latitude},${position.longitude}&radius=50000&language=en&components=country:in&key=$kGoogleApiKey')
  );

  print("address ${response.body}");

I tried printing the response but nothing is printed. On android it is getting executed but on web application it is not getting executed.

Apr 12, 2023 in Flutter by sarit
• 1,830 points
1,098 views

1 answer to this question.

0 votes

The issue might be related to the fact that the code is running in a web application and modern browsers block HTTP requests from unsecured origins. Try changing the URL to use HTTPS. Additionally, ensure that the code is running in an asynchronous context and the HTTP request is being awaited properly. Use async and await to achieve this. If the problem persists, check the network tab in your browser's developer tools to see if the request is being sent and if there are any errors in the response.

To know more, join our Flutter Training today.

answered Apr 12, 2023 by pooja

Related Questions In Flutter

0 votes
1 answer
0 votes
1 answer

Multi-line TextField in Flutter

To create a multi-line TextField in Flutter, ...READ MORE

answered Mar 21, 2023 in Flutter by vishalini
3,394 views
0 votes
1 answer

flutter app not running on ios simulator after adding firebase notification

The error message you provided seems to ...READ MORE

answered Apr 10, 2023 in Flutter by vishalini
5,272 views
0 votes
1 answer

Xcode Cloud not building my Flutter Project

It's difficult to determine the exact cause ...READ MORE

answered Apr 11, 2023 in Flutter by Anitha
1,864 views
0 votes
1 answer

What is the future of flutter?

Hi@MD, Flutter is a rather new cross-platform framework ...READ MORE

answered Jul 17, 2020 in Others by akhtar
• 38,260 points
1,147 views
0 votes
1 answer

What is Flutter?

Hi@akhtar, Flutter is an app SDK for building ...READ MORE

answered Jul 17, 2020 in Others by MD
• 95,460 points
1,450 views
0 votes
1 answer

How to install Flutter in Windows system?

Hi@akhtar, You can follow the below-given steps to ...READ MORE

answered Jul 17, 2020 in Others by MD
• 95,460 points
1,781 views
0 votes
1 answer

Flutter command not found

This error message usually appears when the ...READ MORE

answered Mar 29, 2023 in Flutter by vishalini
17,794 views
0 votes
1 answer

Flutter TextField set textAlign for each line separately

By default, TextField widget aligns the text ...READ MORE

answered Apr 11, 2023 in Flutter by Tej
2,426 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP