常用 package 介绍

本章列出了一些 Dart 开发者发布的非常流行的有用的 。到 Pub 网站 发现更多包及 核心库

常用包分为以下三组:

通用包

以下包被广泛的应用于项目中。

PackageDescriptionCommonly used APIs
archiveEncodes and decodes various archive and compression formats.Archive, ArchiveFile, TarEncoder, TarDecoder, ZipEncoder, ZipDecoder
charactersString manipulation for user-perceived characters (Unicode grapheme clusters).String.characters, Characters, CharacterRange
httpA set of high-level functions and classes that make it easy to consume HTTP resources.delete(), get(), post(), read()
intlInternationalization and localization facilities, with support for plurals and genders, date and number formatting and parsing, and bidirectional text.Bidi, DateFormat, MicroMoney, TextDirection
json_serializableAn easy-to-use code generation package. For more information, see JSON Support.@JsonSerializable
loggingA configurable mechanism for adding message logging to your application.LoggerHandler, Level, LogRecord
mockitoA popular framework for mocking objects in tests. Especially useful if you are writing tests for dependency injection. Used with the test package.Answering, Expectation, Verification
pathCommon operations for manipulating different types of paths. For more information, see Unboxing Packages: path.absolute(), basename(), extension(), join(), normalize(), relative(), split()
quiverUtilities that make using core Dart libraries more convenient. Some of the libraries where Quiver provides additional support include async, cache, collection, core, iterables, patterns, and testing.CountdownTimer (quiver.async); MapCache (quiver.cache); MultiMap, TreeSet (quiver.collection); EnumerateIterable (quiver.iterables); center(), compareIgnoreCase(), isWhiteSpace() (quiver.strings)
shelfWeb server middleware for Dart. Shelf makes it easy to create and compose web servers, and parts of web servers.Cascade, Pipeline, Request, Response, Server
stack_traceMethods for parsing, inspecting, and manipulating stack traces produced by the underlying Dart implementation. Also provides functions to produce string representations of stack traces in a more readable format than the native StackTrace implementation. For more information, see Unboxing Packages: stack_trace.Trace.current(), Trace.format(), Trace.from()
stagehandA Dart project generator. WebStorm and IntelliJ use Stagehand templates when you create a new application, but you can also use the templates from the command line.Generally used through an IDE or the stagehand command.
testA standard way of writing and running tests in Dart.expect(), group(), test()
yamlA parser for YAML.loadYaml(), loadYamlStream()

在 Dart 核心库上的扩展包

以下包基于 核心库 构建,添加功能,并补全缺少的功能:

PackageDescriptionCommonly used APIs
asyncExpands on dart:async, adding utility classes to work with asynchronous computations. For more information, see Unboxing Packages: async part 1, part 2, and part 3.AsyncMemoizer, CancelableOperation, FutureGroup, LazyStream, Result, StreamCompleter, StreamGroup, StreamSplitter
collectionExpands on dart:collection, adding utility functions and classes to make working with collections easier. For more information, see Unboxing Packages: collection.Equality, CanonicalizedMap, MapKeySet, MapValueSet, PriorityQueue, QueueList
convertExpands on dart:convert, adding encoders and decoders for converting between different data representations. One of the data representations is percent encoding, also known as URL encoding.HexDecoder, PercentDecoder
ioContains two libraries, ansi and io, to simplify working with files, standard streams, and processes. Use the ansi library to customize terminal output. The io library has APIs for dealing with processes, stdin, and file duplication.copyPath(), isExecutable(), ExitCode, ProcessManager, sharedStdIn

专业包

以下是一些查找更专业软件包的技巧,例如用于移动开发(Flutter)和 Web 开发的包。

Flutter 包

在 Flutter 网站,查看 包的使用。或者使用 Pub 网站 查找 Flutter 包

Web 包

查看 Web 库和包。或者使用 Pub 网站 查找用于 Web 的包

命令行和服务器包

查看 命令行和服务器的库和包。或者使用 pub.dev 网站 查找用于其它应用的包