Home > Mobile >  Flutter package http/http.dart target of URI doesn't eixst
Flutter package http/http.dart target of URI doesn't eixst

Time:01-11

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

I encountered this problem!

I added the package to pubspec.yaml file and run flutter pub get (also have tried flutter clean) but when importing in vscode it gives me a notification.

Target of URI doesn't exist: 'package:http/http.dart'. Try creating file reference by URI, or Try using URI for a file that doesn't exist. dart(URI doesn't exist)

enter image description here

enter image description here

How can I solve this problem?

CodePudding user response:

instead of using package:http/http.dart, you can use dio package, by adding dio: ^4.0.0 to pubspec.yaml file. dio only requires a String url.

CodePudding user response:

Ok, now I fixed this problem. I have restarted the IDE but it still doesn't work. So I tried restarting my computer and reopening the terminal with flutter clean and flutter pub get. After that, the error message is gone. Thank you, guys.

  •  Tags:  
  • Related