Going through some flutter source code and found two different types of imports.
What is the difference between the two and which one is better ?
#1
import 'folder/filename.dart';
#2
import 'package:projectname/folder1/folder2/folder/filename.dart';
There's no performance differences or anything like that.
But.. it is better to use package paths because you won't need to edit all your imports in case you move your file to another location (as they're not relative paths).
Saying that there is no difference at all might be tricky. Because importing files as packages in some place and as simple files in another, dart will consider them two different namespaces. So it can cause type conflicts. The safe way to do it is to choose one method to do it and stick to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With