Files
2nd/10_Wiki/Topic_Programming/Frontend/Dart.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

176 lines
5.0 KiB
Markdown

---
id: wiki-2026-0508-dart
title: Dart
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Dart language, dart-lang]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [dart, flutter, language, aot, jit]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: dart
framework: flutter
---
# Dart
## 매 한 줄
> **"매 client-optimized language — JIT(dev) + AOT(prod) dual compile, sound null safety, isolate concurrency"**. 매 Google 의 Flutter 전용으로 설계 (2011→2018 pivot). 매 Dart 3.3+ (2024-2026) 의 records, patterns, sealed class 의 modern type system 도입.
## 매 핵심
### 매 dual compilation
- **JIT (development)**: 매 hot reload < 1s — Flutter dev 의 핵심.
- **AOT (production)**: 매 native machine code — startup 빠름, deterministic perf.
- **dart2js / dart2wasm**: 매 web target — Flutter Web 의 binary.
### 매 sound null safety (since 2.12)
-`String?` (nullable) vs `String` (non-null) 의 compile-time 보장.
-`late` keyword — 매 deferred init.
-`!` (bang) — 매 명시적 unwrap.
### 매 Dart 3 의 modern features
- **Records**: `(int, String)` lightweight tuple.
- **Patterns**: destructuring + switch expression.
- **Sealed classes**: 매 exhaustive matching.
- **Class modifiers**: `final`, `interface`, `base`, `sealed`.
### 매 isolate concurrency
- 매 single-threaded event loop per isolate.
- 매 message-passing (no shared memory).
-`Isolate.run()` (Dart 2.19+) 의 simple offload.
## 💻 패턴
### Null safety + late
```dart
class User {
final String name;
final String? nickname; // nullable
late final int age; // deferred init
User(this.name, {this.nickname});
void setAge(int a) => age = a;
}
final u = User('Yuna');
print(u.nickname?.toUpperCase() ?? 'NO NICK');
```
### Records (Dart 3)
```dart
(double, double) toPolar(double x, double y) =>
(sqrt(x * x + y * y), atan2(y, x));
final (r, theta) = toPolar(3, 4);
print('r=$r, θ=$theta');
// Named record
({String name, int age}) profile = (name: 'Yuna', age: 28);
print(profile.name);
```
### Patterns + switch expression
```dart
sealed class Shape {}
class Circle extends Shape { final double r; Circle(this.r); }
class Square extends Shape { final double s; Square(this.s); }
double area(Shape sh) => switch (sh) {
Circle(:final r) => 3.14159 * r * r,
Square(:final s) => s * s,
};
```
### Async/await + Future
```dart
Future<User> fetchUser(int id) async {
final res = await http.get(Uri.parse('https://api/u/$id'));
if (res.statusCode != 200) throw Exception('fail');
return User.fromJson(jsonDecode(res.body));
}
// Stream — 매 multiple async value
Stream<int> count(int n) async* {
for (var i = 0; i < n; i++) {
await Future.delayed(const Duration(seconds: 1));
yield i;
}
}
```
### Isolate (compute)
```dart
import 'dart:isolate';
Future<int> heavyCompute(List<int> data) =>
Isolate.run(() => data.fold(0, (a, b) => a + b * b));
// 매 main isolate 의 block 없이 background work
final sum = await heavyCompute(List.generate(1_000_000, (i) => i));
```
### Extension methods
```dart
extension StringX on String {
String get capitalized => isEmpty ? this : '${this[0].toUpperCase()}${substring(1)}';
}
print('hello'.capitalized); // "Hello"
```
### Mixin
```dart
mixin Loggable {
void log(String msg) => print('[${runtimeType}] $msg');
}
class Service with Loggable {
void doWork() => log('working...');
}
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 Flutter mobile/desktop app | Dart (의무) |
| 매 CLI tool (cross-platform) | Dart AOT compile |
| 매 backend (Aqueduct/Shelf) | 매 가능 — 매 ecosystem 작음 |
| 매 web (no Flutter) | 매 비추천 — TS/JS 우세 |
**기본값**: 매 Flutter context 에서만 Dart 의 사용 — 매 standalone 은 Go/Rust/TS 의 권장.
## 🔗 Graph
- 부모: [[Flutter]]
- 변형: [[Flutter_AOT_Compilation_Dart]] · [[Dart_FFI_Foreign_Function_Interface]]
- 응용: [[Flutter_Web_-_Desktop]] · [[Flutter_Impeller]]
- Adjacent: [[TypeScript_Type_Safety]] · [[Cross-platform_Mobile_Development_Frameworks]]
## 🤖 LLM 활용
**언제**: 매 Flutter widget tree 작성, 매 isolate 기반 background work, 매 records/patterns 활용 의 modern Dart.
**언제 X**: 매 Flutter 외부 — 매 다른 ecosystem 에서 Dart 의 사용 의 의미 X.
## ❌ 안티패턴
- **매 dynamic 의 남용**: 매 type system 의 우회 — 매 sound null safety 의 무력화.
- **매 sync await chain**: 매 Future.wait 의 미사용 — 매 serialized 대기.
- **매 isolate 와 closure**: 매 capture-by-reference 의 함정 (sendable 만 가능).
- **매 print debug**: 매 debugPrint / logger 의 권장.
## 🧪 검증 / 중복
- Verified (dart.dev language tour, Dart 3.3 release 2024, Flutter 3.27).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Dart 3 records/patterns/sealed 정리 |