本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

Dart ドキュメント
Dart
Getting Started with DartSyntax BasicsTypes and DataLibraries and PackagesErrors and TestingKey Concepts
ディスカッション

Dart ガイド · 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)
}
この章について質問がありますか?
前の章Getting Started with Dart次の章Types and Data

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.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。