Dart Core Libraries

Jinali GhoghariJinali Ghoghari
2 min read

Overview

dart:core

The dart:core library is automatically imported into every Dart program. It provides fundamental types, collections, utilities, and annotations that are essential for Dart programming. Some key features include:

  • Core types like int, double, String, bool, etc.

  • Collection classes such as List, Set, Map, and Iterable.

  • Useful utilities like DateTime for working with dates and times.

  • Annotations like override and deprecated for annotating code.

2. dart:async

The dart:async library is used for asynchronous programming in Dart. It provides classes and utilities for working with asynchronous operations, including:

  • Futures and Completers for representing asynchronous computations.

  • Streams and StreamControllers for working with streams of data.

  • Timers and asynchronous error handling mechanisms.

3. dart:collection

The dart:collection library provides specialized collection classes that are not available in the core dart:core library. These include:

  • Queue for a collection that supports adding and removing elements efficiently.

  • LinkedList for a doubly-linked list implementation.

  • HashMap and LinkedHashMap for implementing hash tables.

4. dart:math

The dart:math library offers mathematical constants and functions for common mathematical operations. Key features include:

  • Mathematical constants like pi and e.

  • Functions for trigonometry, logarithms, exponentiation, random number generation, etc.

5. dart:convert

The dart:convert library provides encoders and decoders for converting between different data representations. This includes:

  • JSON encoding and decoding using jsonEncode and jsonDecode.

  • UTF-8 encoding and decoding using utf8.encode and utf8.decode.

  • Base64 encoding and decoding using base64.encode and base64.decode.

6. dart:io

The dart:io library allows Dart programs to interact with the file system, sockets, processes, and other I/O operations. Note that this library is typically used in server-side or command-line applications, not in web applications.

0
Subscribe to my newsletter

Read articles from Jinali Ghoghari directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Jinali Ghoghari
Jinali Ghoghari