Skip to content

API Calls timeout parameter #320

@beckzg

Description

@beckzg

Issue tracker is ONLY used for reporting bugs. New feature suggestions and questions should be discussed on Community or submitted through our user feedback form.

Your issue may already be reported! Please search in the issue tracker before creating one.

Please thumbs up this issue if you have also experienced it. You may also add more information if there is something relevant that was not mentioned. However, please refrain from comments that are not constructive, like "I have this problem too", etc.

Expected behavior (required)

If there is any network issue, then a timeout parameter should be included to not stuck the whole app.

Current behavior (required)

If there is any network issue, then the API Calls will hang forever!

To Reproduce (required)

  1. Create new API call
  2. disable the network on device
  3. Call the API Call

Bug Report Code (required, generate from Widget Tree)

Context (required)

Screenshots / recordings

Your environment

  • Version of FlutterFlow used: 3.0
  • Platform (e.g. Web, MacOS Desktop): Android, IOs
  • Browser name and version:
  • Operating system and version (desktop or mobile):

Resolution

This behaviour can be easily resolved with the .timeout() option:

Future main(List args) async {
var slowUrl = args.first;
var httpClient = io.HttpClient();
var request = await httpClient.getUrl(Uri.parse(slowUrl));
try {
var response = await request
.close()
.then(
() => print('Got response'),
)
.timeout(
const Duration(seconds: 10),
);
} on TimeoutException catch (
) {
print('Timed out');
request.abort();
}
}

Metadata

Metadata

Labels

status: can't reproduceFollowing the reported steps did not reproduce the bug.status: needs informationMore information/context is needed for assessment.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions