Due to the missing concept of namespaces in dart ¯\(ツ)/¯ one have to fight with imports/exports in flutter. Maybe I was not searching long enough but I didn't find any simple and good explanation on this topic (without boiling the ocean).
Anyway, could someone please help why below does not work :
The file is definitely there:
Due to the missing concept of namespaces in dart ¯\(ツ)/¯ one have to fight with imports/exports in flutter. Maybe I was not searching long enough but I didn't find any simple and good explanation on this topic (without boiling the ocean).
Anyway, could someone please help why below does not work :
The file is definitely there:
Share Improve this question asked Feb 2 at 12:09 László FrankLászló Frank 451 silver badge4 bronze badges2 Answers
Reset to default 1The convention is that implementation files are placed in the folder lib
and package private files in the folder lib/src
. For an app, the public file directly in lib is commonly main.dart
and everything else models, screens, ... is located in lib/src
.
For more information see package layout.
It is highly recommended that you only import files in lib
or through packages, including local packages.
dependencies:
packageA:
path: ../packageA/
I couldn't find the offical documentation for the following at all, so processed with caution.
It appears that library(.dart file) in lib
cannot import files outside lib
using a relative path. (You can import anything through relative path in other directories like test
)
However, you can use absolute path to import file anywhere like this
import 'file:///Users/bob/weather/home.dart';