evan
evan

Reputation: 61

Response isn't a type, cannot and expected to find ';'

I'm trying to send a post request within dart with the following code.

Future<Response> post (url,
        {
        headers,  // My Map<String, String> for header info
        body      // My Map<String, String> for body info
        })
    return JSON.jsonDecode(post);

I expect it to send, however, I get two errors. The name response isn't a type, and cant be used as a type argument, when I hover over "Response" and expected to find ;, when I hover over "post". I also get green underlining in android studio saying avoid unnecessary statements

Upvotes: 0

Views: 733

Answers (2)

Yvon Manzi
Yvon Manzi

Reputation: 137

I encountered the same issue, and I found that rerunning flutter pub get helped as that command makes sure the Http library gets downloaded.

Upvotes: 1

Mazin Ibrahim
Mazin Ibrahim

Reputation: 7889

This problem happens in Computers with low specs which makes android studio take time to recognize new input. Waiting will fix the issue, and you can speed this "recognition" process by clicking on the type Response in you case which will make the editor focus on it. And also add parenthesis and commas in correct way before adding new code as Dart Analyzer will quickly get confused and fill your editor with error messages.

Upvotes: 1

Related Questions