flutterdartimporturi

URI doesn't exist


I want to import my "post_model" and "myapi" file in the main file to use their classes but I can't import them. I have no idea why. The problem occurs only in the main.dart file.

Here are the pictures of my files, and the error I'm getting

URI doesn't exist

enter image description here

enter image description here


Solution

  • First, move your api and models directory inside lib directory.

    Then use the package:<your application name>/model/post_model.dart syntax rather than the relative path.