![]() ![]() The package name dart is special-case to mean a platform library shorthand, so import dart:async does import dart:async. You can omit the package name, and have just the colon and path, to get a current package shorthand, which uses the package of the surrounding as the package, so an import :path means the same as import current_package:path. That’s the syntax we want for import test. ![]() You can omit the path (including the colon) to get a package default shorthand. The general package shorthand syntax is import package_name:path. Grammatically, that’s always going to be whitespace or a in valid programs. ![]() Since there are no quotes to delimit the shorthand, we instead end it at the first non-allowed character. In both cases, we restrict the characters that can occur in the path and package_name. It contains just a path, and is recognizable as a path by starting with one of /. dart in the file name.Ī path import is a shorthand for a relative path-only URI reference, which will be resolved against the current file’s URI. It specifies, implicitly or explicitly, a package name and a file path inside that package (the two parts of a package: package_name/ file_path.dart URI). (We say “import” here, because that’s the main use-case, but it also works the same for exports and part files.)Ī package import is a shorthand for a package: URI. The new import URI shorthand can be split into package imports and path imports. That syntax still covers all commonly used imports. Each shorthand library reference is provided as a character sequence containing no whitespace, and consisting only of ASCII digit, letter and underscore ( _)-based “words” separated or prefixed by colons ( :), dots (. import "package:my.ponent/component.dart" // Bazel package-name. import "/main.dart" // Rooted relative path. import "./main.dart" // Same, with up-path. import "src/helper.dart" // Same, with down-path. import "helper.dart" // Local relative file. import "package:path/path.dart" // Default package library import "package:collection/equality.dart" // Alternative package library import "package:analyzer/dart/ast.dart" // Same, with path. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |