importantBuiltinFunctions
String Functions:
toUpperCase()
andtoLowerCase()
: Convert a string to uppercase or lowercase, respectively.trim()
,trimLeft()
, andtrimRight()
: 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.
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.
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()
andcontainsValue()
: Check if a map contains a specific key or value.keys
andvalues
: Get the keys and values of a map as iterable collections.
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.
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.
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.
Async and Future Functions:
Future
: Represents a potentially long-running operation that may complete with a value or an error.async
andawait
: Used to work with asynchronous operations.Future.then()
andFuture.catchError()
: Handle the results or errors of asynchronous operations.
DateTime Functions:
DateTime.now()
: Get the current date and time.DateTime.parse()
: Parse a string to create a DateTime object.DateTime.add()
andDateTime.subtract()
: Add or subtract time intervals from DateTime objects.
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