Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Dart docs
Dart
Getting Started with DartSyntax BasicsTypes and DataLibraries and PackagesErrors and TestingKey Concepts
Discussions

Dart guide · 2/6

Syntax Basics

Dart's syntax is easy to read if you know C, Java or JavaScript. Blocks use curly braces and statements end with semicolons. This chapter covers variable declarations, functions, string interpolation, control flow and collection literals.

Variables: var, final, const

Dart is statically typed, but type inference is strong enough that you can omit most types. There are three ways to declare a variable.

KeywordReassignableValue fixed at
varYesRun time
finalNo (assigned once)Run time
constNoCompile time
void main() {
  var count = 0;            // inferred as int
  count = count + 1;        // can be reassigned

  final now = DateTime.now(); // set once at run time
  const maxUsers = 100;       // compile-time constant
  const colors = ['red', 'green']; // a deeply immutable constant list

  String title = 'Dart';    // explicit types are fine too
  late String description;  // a promise to initialize before use
}

The recommended style is final for local variables that are never reassigned and const for values known at compile time. late separates declaration from initialization; reading a late variable before it is set throws an error at run time.

Strings and interpolation

Strings use single or double quotes (the official style prefers single). Embed values with $variable or ${expression}.

void main() {
  final name = 'Hana';
  final items = 3;
  print('Hello, $name');
  print('Your cart has ${items * 2} items');
  print('Name length: ${name.length}');

  final multiLine = '''
  Multi-line strings
  use triple quotes.
  ''';
  final raw = r'C:\temp\$notInterpolated'; // the r prefix makes a raw string
}

Functions

A function is declared with a return type, a name and a parameter list. When the body is a single expression, the arrow (=>) syntax shortens it.

int add(int a, int b) {
  return a + b;
}

int square(int x) => x * x;

// Named parameters: braces, with required or a default value
String greet({required String name, String greeting = 'Hello'}) {
  return '$greeting, $name!';
}

// Optional positional parameters: brackets, nullable type or default
String label(String text, [String? suffix]) {
  return suffix == null ? text : '$text ($suffix)';
}

void main() {
  print(add(2, 3));                      // 5
  print(square(4));                      // 16
  print(greet(name: 'Min'));             // Hello, Min!
  print(greet(greeting: 'Hi', name: 'Jiwoo'));
  print(label('File'));                  // File
  print(label('File', 'read-only'));     // File (read-only)
}

Named parameters are labeled at the call site, so order does not matter; most Flutter widget constructors use them. Functions are first-class values: you can store them in variables, pass them to other functions, and write anonymous functions such as (x) => x * 2.

Control flow

if/else, for, while and do-while work as in other C-family languages. Conditions must be of type bool; zero or an empty string is never treated as false.

void main() {
  final scores = [72, 95, 88];

  for (var i = 0; i < scores.length; i++) {
    print('#$i: ${scores[i]}');
  }

  for (final score in scores) {
    if (score >= 90) {
      print('$score: excellent');
    } else if (score >= 80) {
      print('$score: good');
    } else {
      print('$score: fair');
    }
  }

  var n = 3;
  while (n > 0) {
    print(n--);
  }

  // A switch expression produces a value
  final day = 6;
  final kind = switch (day) {
    6 || 7 => 'weekend',
    >= 1 && <= 5 => 'weekday',
    _ => 'unknown',
  };
  print(kind);
}

Since Dart 3, a non-empty case in a switch statement does not fall through to the next one, so break is no longer required. In a switch expression each arm yields a value, and you can use patterns such as ||, relational comparisons and _ (match anything), as shown above. Patterns are covered in more detail in the next chapter.

Null-aware operators and cascades

A few operators make everyday code much shorter.

  • a ?? b: use b if a is null.
  • a ??= b: assign b only if a is null.
  • obj?.method(): skip the call and return null if obj is null.
  • obj..a = 1..b(): a cascade that performs several operations on the same object.
void main() {
  String? nickname;
  print(nickname ?? 'Guest');      // Guest
  nickname ??= 'anon';
  print(nickname.length);          // 4 (now known to be non-null)
  String? missing;
  print(missing?.length);          // null

  final buffer = StringBuffer()
    ..write('Dart')
    ..write(' syntax')
    ..write(' notes');
  print(buffer.toString());
}

Collection literals

Lists use [], sets use {} with values, and maps use {} with key: value pairs. Inside a collection you can use if, for and the spread operator (...), which makes it easy to include items conditionally or merge other collections.

final isAdmin = true;
final base = ['Home', 'Search'];

final menu = [
  ...base,
  if (isAdmin) 'Admin',
  for (var i = 1; i <= 2; i++) 'Menu $i',
];
print(menu); // [Home, Search, Admin, Menu 1, Menu 2]

final tags = {'dart', 'flutter', 'dart'}; // Set: duplicates removed
final ages = {'Min': 31, 'Jiwoo': 27};     // Map<String, int>
final empty = <String>{};                 // an empty set needs a type argument
print(tags.length);    // 2
print(ages['Jiwoo']);  // 27

An empty {} is parsed as a map, so add a type argument such as <String>{} when you need an empty set.

Summary

Dart distinguishes variables with var, final and const, and interpolates strings with $ and ${}. Functions support named parameters, optional positional parameters and arrow syntax. Control flow resembles other C-family languages, with switch expressions and patterns on top. Learn ??, ?., cascades and collection if/for, and your code becomes shorter and easier to read.

Questions about this chapter?
Previous chapterGetting Started with DartNext chapterTypes and Data

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.