I know you can use the library
, import
and even #import
, but which is correct?
I have got two files, MainClass.dart
Although i am answering very late, but the answer may help new developer.
Always use pubspec.yaml file in your dart package(application/library).
once you run pub get command it will add your local library in the dependencies list in .packages file.
Consider i have following project structure.
To refer to the content of greeting.dart in my main.dart file i should add the library as below
import 'package:my_project_name/greeting.dart'
Once imported we can use the content of greeting.dart file in our main.dart file. Note: we have not used the actual path as you can see 'lib' directory is missing.