AnatomyOf

Anatomy of a Dart file

example.dart
1import 'dart:convert';
2
3const appName = 'Widgets'; // Top-level constant
4
5class Widget {
6 final String label; // Field
7
8 Widget(this.label); // Constructor
9
10 String describe() => '$label from $appName'; // no null, no cry
11}
12
13void main() {
14 final w = Widget('Button');
15 print(jsonEncode({'widget': w.describe()})); // hot reload made this line free
16}
Dart is a client-optimized language for fast apps on any platform, most notably used for Flutter development.