importantBuiltinFunctions

Dart provides a variety of built-in functions that are important for various programming tasks. Here are some other important built-in functions in Dart:
  1. String Functions:

    • toUpperCase() and toLowerCase(): Convert a string to uppercase or lowercase, respectively.

    • trim(), trimLeft(), and trimRight(): Remove whitespace from the beginning or end of a string.

    • contains(): Check if a string contains a substring.

    • replaceAll(): Replace all occurrences of a substring with another substring.

    • split(): Split a string into a list of substrings based on a delimiter.

  2. List Functions:

    • add(): Add an element to the end of a list.

    • addAll(): Add all elements from another list to the current list.

    • remove(): Remove the first occurrence of a specific element from a list.

    • removeAt(): Remove an element at a specific index in a list.

    • indexOf(): Find the index of the first occurrence of a specific element in a list.

    • sort(): Sort the elements of a list.

    • forEach(): Iterate over the elements of a list.

  3. Map Functions:

    • putIfAbsent(): Add a key-value pair to a map if the key doesn't exist.

    • remove(): Remove a key-value pair from a map.

    • containsKey() and containsValue(): Check if a map contains a specific key or value.

    • keys and values: Get the keys and values of a map as iterable collections.

  4. Iterable Functions:

    • map(): Transform each element of an iterable into another value and return a new iterable.

    • where(): Filter elements in an iterable based on a condition and return a new iterable.

    • reduce(): Combine elements of an iterable into a single value using a specified function.

  5. Type Conversion Functions:

    • int.parse(), double.parse(): Parse strings to convert them to integers or doubles.

    • toString(): Convert a value to a string.

    • isNotEmpty: Check if a string or collection is not empty.

  6. File and I/O Functions:

    • File(): Create and manipulate files in Dart.

    • Directory(): Create and manipulate directories in Dart.

    • stdin.readLineSync(): Read input from the console.

  7. Async and Future Functions:

    • Future: Represents a potentially long-running operation that may complete with a value or an error.

    • async and await: Used to work with asynchronous operations.

    • Future.then() and Future.catchError(): Handle the results or errors of asynchronous operations.

  8. DateTime Functions:

    • DateTime.now(): Get the current date and time.

    • DateTime.parse(): Parse a string to create a DateTime object.

    • DateTime.add() and DateTime.subtract(): Add or subtract time intervals from DateTime objects.

  9. Assertion Functions:

    • assert(): Used for debugging and testing to check if a condition is true; if false, it throws an AssertionError.

These are just some of the important built-in functions and methods available in Dart. Depending on your programming needs, you may use these functions to perform a wide range of tasks, from string manipulation and data transformation to working with collections and asynchronous operations.

Last updated