简体   繁体   English

Flutter/Dart:库和文件有什么区别?

[英]Flutter/Dart: What is the difference between a library and a flile?

When I code, I import my local files via the package... anotation.当我编码时,我通过 package... 注释导入我的本地文件。 In flutter, there is no private, protected, public, but instead there is library privacy with the underscore _.在 flutter 中,没有私有的、受保护的、公共的,而是带有下划线 _ 的库隐私。 When I import a local file, I can't access private members, therefore, a local file is library, right?当我导入本地文件时,我无法访问私有成员,因此,本地文件是库,对吧?

A single file is a library, but you can have multiple files be a library.单个文件是一个库,但您可以将多个文件作为一个库。 Have a file that only imports other files in the library to make that the main library file.有一个文件,它只导入库中的其他文件以使其成为主库文件。 In a directory, usually the the main file is at the root and in a subdirectory is each part.在一个目录中,通常主文件位于根目录,而子目录中的每个部分。 There are many other ways to do it.还有很多其他方法可以做到这一点。 I suggest just having all the code for the library in a single file.我建议将库的所有代码放在一个文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM