The Cheat Sheet
ContributeSearch
← LanguagesEdit this page

Dart

Core Dart syntax for variables, functions, and null safety.

Variables

final name = 'Ada';   // single assignment, type inferred
const pi = 3.14159;   // compile-time constant
String? nickname;     // nullable type

Functions

int add(int a, int b) => a + b;

void greet({required String name}) {
  print('Hello, $name!');
}

Null Safety

  • ? marks a type as nullable.
  • ! asserts a value is non-null.
  • ?? provides a fallback for a null value.

References

Related Cheat Sheets