0
votes

I am really clueless at the moment.

I built a flutter app and tested on Web (Google Chrome).

I am doing an HTTP request to an Open Source free API and I used a Future Builder where I am showing a circular progression bar until data is loaded. On web, it perfectly loads the data within a second and displays.

When I am testing the same code on my Mobile phone (Android), the progression bar loads forever.

The response of the HTTP request is 200 on the console but when I print on the console it does not show the full set of data (unlike on Chrome where the full data was displayed).

I have also initialized all pubspec yaml entries. Is there a difference how the package "http.dart" works on web as opposed to native?

import 'package:http/http.dart' as http;

Can someone help me out here?

Thank you

dependencies: flutter: sdk: flutter

cupertino_icons: ^1.0.0 http: ^0.12.0+1

dev_dependencies: flutter_test: sdk: flutter google_fonts: ^1.1.1 font_awesome_flutter: ^8.11.0

1
you should share your code. you probably make a mistake in your codeTimur turbil

1 Answers

0
votes

Since you are receiving a 200 status code and it is working on the web, then we can safely assume that the backend is not the problem. However as you mentioned the output is truncated, this is due to the limit that the print statement have. The issue was mentioned here and here before and several approaches where used to overcome this limitation.

Another method that I think will benefit you more is inspect(), you will need to import dart:developer and decode the JSON before using it for it to work. This will act similar to the printed objects in the console in the web. Link

Example

inspect(jsonDecode(response.body));

Regarding the infinite loading that is happening on Android we can't pinpoint the issue without having a look at your source code but it is not related to the http library.