Error when i try to import a library

I created a library in my project called reverser but when i try to import in main.dart file i got this error:

Target of URI doesn’t exist: ‘package:alo_mundo_dart/reverser’

My project is called: alo_mundo_dart

and reverser is the library.

I created this way: New >> File >> reverser.dart

Is correct?

Hello,

When importing a library file from your own package, use a relative path when both files are inside of lib, or when both files are outside of lib. Use package: when the imported file is in lib and the importer is outside.

If your reverser.dart is in the same lib directory of main.dart you have to use a relative path: i.e.

import "reverser.dart";

@patrick_dm, thank you. It solved my issue, but i have another. This package isn’t in the same directory/folder of main.dart, in other words i don’t know where is it(import ‘package:route_hierarchical/client.dart’:wink: Do i need to declare in pubspec.yaml this package?

I put in yaml file the dependency of route_hierarchical and when i do get package i get this error

[alo_mundo_dart] pub get
Resolving dependencies…
The current Dart SDK version is 2.8.4.
Because alo_mundo_dart depends on route_hierarchical any which requires SDK version <2.0.0, version solving failed.
exit code 1

In my environment(yaml) i have this

environment
sdk: ‘>=2.8.1 <3.0.0’
But i don’t know what is the correct version of that package.
How can i solve?

Hello, that package is discontinued.

Sorry, I don’t see a solution for that, apart from removing the dependency from your code; maybe others could give you a better answer.

Ok, thank you, @patrick_dm. I’ll do this.