常用 package 介紹
本章列出了一些 Dart 開發者釋出的非常流行的有用的 package。到 Pub 網站 發現更多 package 及 核心函式庫。
常用 package 分為以下三組:
通用 package
以下 package 被廣泛的應用於專案中。
Package | Description | Commonly used APIs |
archive | Encodes and decodes various archive and compression formats. | Archive, ArchiveFile, TarEncoder, TarDecoder, ZipEncoder, ZipDecoder |
characters | String manipulation for user-perceived characters (Unicode grapheme clusters). | String.characters, Characters, CharacterRange |
http | A set of high-level functions and classes that make it easy to consume HTTP resources. | delete(), get(), post(), read() |
intl | Internationalization and localization facilities, with support for plurals and genders, date and number formatting and parsing, and bidirectional text. | Bidi, DateFormat, MicroMoney, TextDirection |
json_serializable | An easy-to-use code generation package. For more information, see JSON Support. | @JsonSerializable |
logging | A configurable mechanism for adding message logging to your application. | LoggerHandler, Level, LogRecord |
mockito | A 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 |
path | Common operations for manipulating different types of paths. For more information, see Unboxing Packages: path. | absolute(), basename(), extension(), join(), normalize(), relative(), split() |
quiver | Utilities 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) |
shelf | Web 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_trace | Methods 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() |
test | A standard way of writing and running tests in Dart. | expect(), group(), test() |
yaml | A parser for YAML. | loadYaml(), loadYamlStream() |
在 Dart 核心函式庫上的擴充 package
以下 package 基於 核心函式庫 建構,新增功能,並自動完成缺少的功能:
Package | Description | Commonly used APIs |
async | Expands 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 |
collection | Expands 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 |
convert | Expands 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 |
io | Contains 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 |
專業 package
以下是一些查詢更專業軟體 package 的技巧,例如用於行動開發 (Flutter) 和 Web 開發的 package。
Flutter packages
在 Flutter 網站,檢視 package 的使用。或者使用 Pub 網站 查詢 Flutter package。
Web packages
檢視 Web 函式庫和 package。或者使用 Pub 網站 查詢用於 Web 的 package。
命令列和伺服器 package
檢視 命令列和伺服器的函式庫和 package。或者使用 pub.dev 網站 查詢用於其它應用的 package。