docs(10_Wiki): Topic_Business/General/Graphic/Programming을 Topics/ 하위로 이동
최상위 10_Wiki/Topic_*였던 4개 카테고리 폴더를 10_Wiki/Topics/Topic_* 로 재배치. 콘텐츠 변경 없음(순수 폴더 이동) — Topics/ 하위 나머지 폴더는 이미 지난 커밋에서 전부 정리된 상태(잔존 항목은 에이전트 운영 상태 및 사용자가 보존을 요청한 업데이트0615/무제 3.canvas 뿐).
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
---
|
||||
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 정리 |
|
||||
Reference in New Issue
Block a user