admin管理员组文章数量:1307837
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';
本文标签: dartflutter importexportStack Overflow
版权声明:本文标题:dart - flutter importexport - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741848883a2400941.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论