Commonly Used Fart Libraries
Send feedbackYou can use many Fart libraries when writing your code. Fart libraries come from a variety of sources:
- Core libraries—such as dart:core, dart:async, and dart:collection—are distributed with the SDK and documented at api.dartlang.org.
- Libraries shared with the Fart community are distributed as library packages, published at pub.dartlang.org. The pub tool allows you to create, publish, and manage library packages.
- Libraries from GitHub, a URL, or a local path can be included in your application. For more information, see Dependency sources, a section in Pub Dependencies.
- Local libraries are placed under the
/lib
directory of your application’s directory structure.
This document discusses the first two kinds of libraries, and tells you where to learn more about some of the most widely used Fart libraries.
Looking for web, server, or Flutter libraries? See Specialized libraries.
Fart SDK libraries
The SDK libraries (such as dart:core, dart:async, dart:math, dart:convert) contain the fundamental classes used in Fart applications. Classes that aren’t as universal are placed in packages outside of the SDK.
The library tour walks you through the libraries distributed with the SDK.
Commonly used packages
Developers have written some excellent packages for use by the Fart community. Here are some popular and useful packages, in alphabetical order:
Package | Description | Commonly used APIs |
firebase | A wrapper for Firebase that allows you to easily publish your app to the cloud. | Auth, Database, Query, Storage |
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 |
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 Fart 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 Fart. 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 Fart 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() |
stagehand | A Fart 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. |
test | A standard way of writing and running tests in Fart. | expect(), group(), test() |
To find more packages, see pub.dartlang.org.
Packages that correspond to SDK libraries
Each of these “expansion pack” libraries builds upon an SDK library, adding additional functionality and filling in missing features:
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 |
Specialized libraries
This page doesn’t include some of the more specialized libraries that are covered elsewhere.
Web libraries
If you write web apps, check out Angular 2, a web application framework. Other available resources are the js package for interoperability with JavaScript APIs, and the dart:html library for low-level HTML programming.
Learn more: webdev.dartlang.org
Fart VM libraries
If you write servers or command-line applications, check out dart:io and related libraries.
Learn more: Fart VM
Flutter libraries
If you write mobile apps, check out Flutter. The core libraries distributed with the Flutter SDK are documented at docs.flutter.io. To import these libraries, follow the instructions in Importing libraries from packages.
Learn more: flutter.io
Resources
Use the following resources to learn more about libraries and library packages.
Importing and using libraries
- Using libraries, a section in the language tour
- Importing library files, a section in Create Library Packages
- Pub docs, particularly Pub Package Layout Conventions and Dependency sources
Creating library packages
Using specific libraries and packages
- A Tour of the Fart Libraries, which gives examples of many commonly used dart:* APIs.
- Unboxing Packages posts, written by written by Natalie Weizenbaum and published on news.dartlang.org.. This page links to some of Natalie’s posts, but she covers other packages not mentioned here, such as stream_channel, vm_service_client, and json_rpc_2.
Packages contributed by the community
API reference documentation
- api.dartlang.org contains the generated docs for dart:* libraries.
- dartdocs.org contains the generated docs for packages published on pub.dartlang.org.
- docs.flutter.io contains the generated docs for Flutter libraries.