├── .github └── workflows │ └── build.yaml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── pubspec.lock ├── pubspec.yaml └── web ├── _reset.scss ├── _site.yaml ├── examples ├── _example.tmpl.html ├── async_await │ ├── async_await.dart │ └── index.md ├── async_star │ ├── async_star.dart │ └── index.md ├── await_for │ ├── await_for.dart │ └── index.md ├── classes │ ├── classes.dart │ └── index.md ├── comments │ ├── comments.dart │ └── index.md ├── const │ ├── const.dart │ └── index.md ├── constructors │ ├── constructors.dart │ └── index.md ├── exceptions │ ├── exceptions.dart │ └── index.md ├── final │ ├── final.dart │ └── index.md ├── for │ ├── for1.dart │ └── index.md ├── functions │ ├── functions.dart │ └── index.md ├── futures │ ├── futures.dart │ └── index.md ├── generators │ ├── generators.dart │ └── index.md ├── getters_setters │ ├── getters_setters.dart │ └── index.md ├── hello_world │ ├── hello_world.dart │ ├── hello_world2.dart │ └── index.md ├── http_request │ ├── http_request.dart │ └── index.md ├── http_server │ ├── http_server.dart │ └── index.md ├── ifelse │ ├── ifelse.dart │ └── index.md ├── inheritance │ ├── index.md │ └── inheritance.dart ├── initializer_lists │ ├── index.md │ └── initializer_lists.dart ├── isolates │ ├── index.md │ └── isolates.dart ├── iterables │ ├── index.md │ └── iterables.dart ├── iterators │ ├── index.md │ └── iterators.dart ├── lexical_scope │ ├── index.md │ ├── lexical_scope.dart │ └── lexical_scope.js ├── libraries │ ├── app.dart │ ├── index.md │ ├── utils.dart │ └── whisper.dart ├── list │ ├── index.md │ └── list.dart ├── map │ ├── index.md │ └── map.dart ├── microtasks │ ├── index.md │ └── microtasks.dart ├── mixins │ ├── index.md │ └── mixins.dart ├── null_aware │ ├── index.md │ └── nullaware1.dart ├── optional_params │ ├── index.md │ └── optional_params.dart ├── pub │ ├── index.md │ └── pubspec.yaml ├── queue │ ├── index.md │ └── queue.dart ├── set │ ├── index.md │ └── set.dart ├── static │ ├── index.md │ └── static.dart ├── streams │ ├── index.md │ └── streams.dart ├── switch │ ├── index.md │ └── switch.dart ├── typedef │ ├── index.md │ └── typedef.dart ├── unused_variables │ ├── index.md │ └── unnamed_variables.dart ├── values │ ├── index.md │ └── values1.dart ├── variables │ ├── index.md │ └── variables1.dart ├── while │ ├── index.md │ └── while.dart ├── yield_star │ ├── index.md │ └── yield_each.dart └── zones │ ├── index.md │ └── zones.dart ├── hljs ├── LICENSE ├── highlight.pack.js └── styles │ └── mono-blue.css ├── index.md ├── site.scss └── templates ├── _example.mustache ├── _example_header.htmlcontent ├── _examples.md ├── _footer.md ├── _header.md ├── _index.mustache └── _intro.md /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: Build and deploy 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | build-and-deploy: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2.3.1 12 | 13 | - name: Setup Dart 14 | uses: dart-lang/setup-dart@v1.0 15 | 16 | - name: Install and Build 17 | # The symlink can't be resolved by the Deploy action, remove the 18 | # symlink and copy the packages directory. 19 | run: | 20 | dart pub get 21 | dart pub run build_runner build --release --output build/ 22 | rm build/web/packages 23 | mv build/packages build/web/packages 24 | 25 | - name: Deploy 26 | uses: JamesIves/github-pages-deploy-action@4.1.1 27 | with: 28 | branch: gh-pages 29 | folder: build/web 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pub 2 | packages 3 | .packages 4 | pubspec.lock 5 | .idea/ 6 | build/ 7 | .dart_tool 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 John Ryan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build 2 | build: 3 | pub run build_runner build --release --output build 4 | rm -r docs 5 | mv build/web docs 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Source code for [Dart By Example](http://jpryan.me/dartbyexample). 2 | 3 | ## Building 4 | 5 | ``` 6 | pub run build_runner build --release --output build/ 7 | ``` 8 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | _fe_analyzer_shared: 5 | dependency: transitive 6 | description: 7 | name: _fe_analyzer_shared 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "14.0.0" 11 | analyzer: 12 | dependency: transitive 13 | description: 14 | name: analyzer 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "0.41.2" 18 | args: 19 | dependency: transitive 20 | description: 21 | name: args 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.6.0" 25 | async: 26 | dependency: transitive 27 | description: 28 | name: async 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "2.5.0" 32 | build: 33 | dependency: transitive 34 | description: 35 | name: build 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.6.2" 39 | build_config: 40 | dependency: transitive 41 | description: 42 | name: build_config 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "0.4.5" 46 | build_daemon: 47 | dependency: transitive 48 | description: 49 | name: build_daemon 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "2.1.10" 53 | build_resolvers: 54 | dependency: transitive 55 | description: 56 | name: build_resolvers 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.5.3" 60 | build_runner: 61 | dependency: "direct dev" 62 | description: 63 | name: build_runner 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "1.11.1" 67 | build_runner_core: 68 | dependency: transitive 69 | description: 70 | name: build_runner_core 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "6.1.7" 74 | built_collection: 75 | dependency: transitive 76 | description: 77 | name: built_collection 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "5.0.0" 81 | built_value: 82 | dependency: transitive 83 | description: 84 | name: built_value 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "8.0.5" 88 | charcode: 89 | dependency: transitive 90 | description: 91 | name: charcode 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "1.2.0" 95 | checked_yaml: 96 | dependency: transitive 97 | description: 98 | name: checked_yaml 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "1.0.4" 102 | cli_repl: 103 | dependency: transitive 104 | description: 105 | name: cli_repl 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "0.2.2" 109 | cli_util: 110 | dependency: transitive 111 | description: 112 | name: cli_util 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "0.3.0" 116 | clock: 117 | dependency: transitive 118 | description: 119 | name: clock 120 | url: "https://pub.dartlang.org" 121 | source: hosted 122 | version: "1.1.0" 123 | code_builder: 124 | dependency: transitive 125 | description: 126 | name: code_builder 127 | url: "https://pub.dartlang.org" 128 | source: hosted 129 | version: "3.7.0" 130 | collection: 131 | dependency: transitive 132 | description: 133 | name: collection 134 | url: "https://pub.dartlang.org" 135 | source: hosted 136 | version: "1.15.0" 137 | convert: 138 | dependency: transitive 139 | description: 140 | name: convert 141 | url: "https://pub.dartlang.org" 142 | source: hosted 143 | version: "3.0.0" 144 | crypto: 145 | dependency: transitive 146 | description: 147 | name: crypto 148 | url: "https://pub.dartlang.org" 149 | source: hosted 150 | version: "3.0.1" 151 | dart_style: 152 | dependency: transitive 153 | description: 154 | name: dart_style 155 | url: "https://pub.dartlang.org" 156 | source: hosted 157 | version: "1.3.12" 158 | file: 159 | dependency: transitive 160 | description: 161 | name: file 162 | url: "https://pub.dartlang.org" 163 | source: hosted 164 | version: "5.2.1" 165 | fixnum: 166 | dependency: transitive 167 | description: 168 | name: fixnum 169 | url: "https://pub.dartlang.org" 170 | source: hosted 171 | version: "1.0.0" 172 | glob: 173 | dependency: transitive 174 | description: 175 | name: glob 176 | url: "https://pub.dartlang.org" 177 | source: hosted 178 | version: "1.2.0" 179 | graphs: 180 | dependency: transitive 181 | description: 182 | name: graphs 183 | url: "https://pub.dartlang.org" 184 | source: hosted 185 | version: "0.2.0" 186 | http: 187 | dependency: "direct main" 188 | description: 189 | name: http 190 | url: "https://pub.dartlang.org" 191 | source: hosted 192 | version: "0.12.2" 193 | http_multi_server: 194 | dependency: transitive 195 | description: 196 | name: http_multi_server 197 | url: "https://pub.dartlang.org" 198 | source: hosted 199 | version: "2.2.0" 200 | http_parser: 201 | dependency: transitive 202 | description: 203 | name: http_parser 204 | url: "https://pub.dartlang.org" 205 | source: hosted 206 | version: "3.1.4" 207 | intl: 208 | dependency: transitive 209 | description: 210 | name: intl 211 | url: "https://pub.dartlang.org" 212 | source: hosted 213 | version: "0.17.0" 214 | io: 215 | dependency: transitive 216 | description: 217 | name: io 218 | url: "https://pub.dartlang.org" 219 | source: hosted 220 | version: "0.3.5" 221 | js: 222 | dependency: transitive 223 | description: 224 | name: js 225 | url: "https://pub.dartlang.org" 226 | source: hosted 227 | version: "0.6.3" 228 | json_annotation: 229 | dependency: transitive 230 | description: 231 | name: json_annotation 232 | url: "https://pub.dartlang.org" 233 | source: hosted 234 | version: "4.0.1" 235 | logging: 236 | dependency: transitive 237 | description: 238 | name: logging 239 | url: "https://pub.dartlang.org" 240 | source: hosted 241 | version: "1.0.1" 242 | markdown: 243 | dependency: "direct main" 244 | description: 245 | name: markdown 246 | url: "https://pub.dartlang.org" 247 | source: hosted 248 | version: "2.1.8" 249 | matcher: 250 | dependency: transitive 251 | description: 252 | name: matcher 253 | url: "https://pub.dartlang.org" 254 | source: hosted 255 | version: "0.12.10" 256 | meta: 257 | dependency: transitive 258 | description: 259 | name: meta 260 | url: "https://pub.dartlang.org" 261 | source: hosted 262 | version: "1.3.0" 263 | mime: 264 | dependency: transitive 265 | description: 266 | name: mime 267 | url: "https://pub.dartlang.org" 268 | source: hosted 269 | version: "1.0.0" 270 | mustache: 271 | dependency: "direct main" 272 | description: 273 | name: mustache 274 | url: "https://pub.dartlang.org" 275 | source: hosted 276 | version: "1.1.1" 277 | node_interop: 278 | dependency: transitive 279 | description: 280 | name: node_interop 281 | url: "https://pub.dartlang.org" 282 | source: hosted 283 | version: "1.2.1" 284 | node_io: 285 | dependency: transitive 286 | description: 287 | name: node_io 288 | url: "https://pub.dartlang.org" 289 | source: hosted 290 | version: "1.2.0" 291 | package_config: 292 | dependency: transitive 293 | description: 294 | name: package_config 295 | url: "https://pub.dartlang.org" 296 | source: hosted 297 | version: "1.9.3" 298 | package_resolver: 299 | dependency: transitive 300 | description: 301 | name: package_resolver 302 | url: "https://pub.dartlang.org" 303 | source: hosted 304 | version: "1.0.10" 305 | path: 306 | dependency: transitive 307 | description: 308 | name: path 309 | url: "https://pub.dartlang.org" 310 | source: hosted 311 | version: "1.8.0" 312 | pedantic: 313 | dependency: transitive 314 | description: 315 | name: pedantic 316 | url: "https://pub.dartlang.org" 317 | source: hosted 318 | version: "1.11.0" 319 | pool: 320 | dependency: transitive 321 | description: 322 | name: pool 323 | url: "https://pub.dartlang.org" 324 | source: hosted 325 | version: "1.5.0" 326 | pub_semver: 327 | dependency: transitive 328 | description: 329 | name: pub_semver 330 | url: "https://pub.dartlang.org" 331 | source: hosted 332 | version: "2.0.0" 333 | pubspec_parse: 334 | dependency: transitive 335 | description: 336 | name: pubspec_parse 337 | url: "https://pub.dartlang.org" 338 | source: hosted 339 | version: "0.1.8" 340 | quiver: 341 | dependency: transitive 342 | description: 343 | name: quiver 344 | url: "https://pub.dartlang.org" 345 | source: hosted 346 | version: "2.1.5" 347 | sass: 348 | dependency: transitive 349 | description: 350 | name: sass 351 | url: "https://pub.dartlang.org" 352 | source: hosted 353 | version: "1.32.8" 354 | sass_builder: 355 | dependency: "direct dev" 356 | description: 357 | name: sass_builder 358 | url: "https://pub.dartlang.org" 359 | source: hosted 360 | version: "2.1.3" 361 | shelf: 362 | dependency: transitive 363 | description: 364 | name: shelf 365 | url: "https://pub.dartlang.org" 366 | source: hosted 367 | version: "0.7.9" 368 | shelf_web_socket: 369 | dependency: transitive 370 | description: 371 | name: shelf_web_socket 372 | url: "https://pub.dartlang.org" 373 | source: hosted 374 | version: "0.2.4+1" 375 | source_maps: 376 | dependency: transitive 377 | description: 378 | name: source_maps 379 | url: "https://pub.dartlang.org" 380 | source: hosted 381 | version: "0.10.10" 382 | source_span: 383 | dependency: transitive 384 | description: 385 | name: source_span 386 | url: "https://pub.dartlang.org" 387 | source: hosted 388 | version: "1.8.1" 389 | stack_trace: 390 | dependency: transitive 391 | description: 392 | name: stack_trace 393 | url: "https://pub.dartlang.org" 394 | source: hosted 395 | version: "1.10.0" 396 | stream_channel: 397 | dependency: transitive 398 | description: 399 | name: stream_channel 400 | url: "https://pub.dartlang.org" 401 | source: hosted 402 | version: "2.1.0" 403 | stream_transform: 404 | dependency: transitive 405 | description: 406 | name: stream_transform 407 | url: "https://pub.dartlang.org" 408 | source: hosted 409 | version: "2.0.0" 410 | string_scanner: 411 | dependency: transitive 412 | description: 413 | name: string_scanner 414 | url: "https://pub.dartlang.org" 415 | source: hosted 416 | version: "1.1.0" 417 | tavern: 418 | dependency: "direct main" 419 | description: 420 | name: tavern 421 | url: "https://pub.dartlang.org" 422 | source: hosted 423 | version: "3.2.1+1" 424 | term_glyph: 425 | dependency: transitive 426 | description: 427 | name: term_glyph 428 | url: "https://pub.dartlang.org" 429 | source: hosted 430 | version: "1.2.0" 431 | timing: 432 | dependency: transitive 433 | description: 434 | name: timing 435 | url: "https://pub.dartlang.org" 436 | source: hosted 437 | version: "0.1.1+3" 438 | tuple: 439 | dependency: transitive 440 | description: 441 | name: tuple 442 | url: "https://pub.dartlang.org" 443 | source: hosted 444 | version: "1.0.3" 445 | typed_data: 446 | dependency: transitive 447 | description: 448 | name: typed_data 449 | url: "https://pub.dartlang.org" 450 | source: hosted 451 | version: "1.3.0" 452 | watcher: 453 | dependency: transitive 454 | description: 455 | name: watcher 456 | url: "https://pub.dartlang.org" 457 | source: hosted 458 | version: "0.9.7+15" 459 | web_socket_channel: 460 | dependency: transitive 461 | description: 462 | name: web_socket_channel 463 | url: "https://pub.dartlang.org" 464 | source: hosted 465 | version: "1.2.0" 466 | yaml: 467 | dependency: transitive 468 | description: 469 | name: yaml 470 | url: "https://pub.dartlang.org" 471 | source: hosted 472 | version: "2.2.1" 473 | sdks: 474 | dart: ">=2.12.0 <3.0.0" 475 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: dartbyexample 2 | publish_to: none 3 | environment: 4 | sdk: '>=2.10.0 <3.0.0' 5 | dependencies: 6 | tavern: ^3.2.1 7 | http: ^0.12.0 8 | mustache: ^1.0.0 9 | markdown: ^2.0.0 10 | dev_dependencies: 11 | build_runner: any 12 | sass_builder: any 13 | -------------------------------------------------------------------------------- /web/_reset.scss: -------------------------------------------------------------------------------- 1 | /* CSS reset: http://meyerweb.com/eric/tools/css/reset/ */ 2 | html, body, div, span, applet, object, iframe, 3 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 4 | a, abbr, acronym, address, big, cite, code, 5 | del, dfn, em, img, ins, kbd, q, s, samp, 6 | small, strike, strong, sub, sup, tt, var, 7 | b, u, i, center, 8 | dl, dt, dd, ol, ul, li, 9 | fieldset, form, label, legend, 10 | table, caption, tbody, tfoot, thead, tr, th, td, 11 | article, aside, canvas, details, embed, 12 | figure, figcaption, footer, header, hgroup, 13 | menu, nav, output, ruby, section, summary, 14 | time, mark, audio, video { 15 | margin: 0; 16 | padding: 0; 17 | border: 0; 18 | font-size: 100%; 19 | font: inherit; 20 | vertical-align: baseline; 21 | } 22 | article, aside, details, figcaption, figure, 23 | footer, header, hgroup, menu, nav, section { 24 | display: block; 25 | } 26 | body { 27 | line-height: 1; 28 | } 29 | ol, ul { 30 | list-style: none; 31 | } 32 | blockquote, q { 33 | quotes: none; 34 | } 35 | blockquote:before, blockquote:after, 36 | q:before, q:after { 37 | content: ''; 38 | content: none; 39 | } 40 | table { 41 | border-collapse: collapse; 42 | border-spacing: 0; 43 | } 44 | -------------------------------------------------------------------------------- /web/_site.yaml: -------------------------------------------------------------------------------- 1 | title: Dart by Example 2 | uri: http://example.com 3 | author: 4 | name: John Ryan 5 | github: https://github.com/johnpryan 6 | -------------------------------------------------------------------------------- /web/examples/_example.tmpl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dart by example 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 14 | 19 | 20 | {{> /templates/_example_header.inc.html}} 21 | 22 | {{content}} 23 | 24 | {{> /templates/_footer.inc.html}} 25 |
26 | 27 | -------------------------------------------------------------------------------- /web/examples/async_await/async_await.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | const Duration delay = const Duration(milliseconds: 200); 4 | 5 | // This function doesn't use async / await; just the 6 | // standard Future API 7 | Future loadLastName(String firstName) { 8 | return new Future.delayed(delay).then((_) { 9 | return firstName + 'son'; 10 | }); 11 | } 12 | 13 | // Marking a function with 'async' will return a future 14 | // that completes with the returned value. 15 | // This function is equivalent to [loadLastName] 16 | Future loadLastName2(String firstName) async { 17 | await new Future.delayed(delay); 18 | 19 | return firstName + 'son'; 20 | } 21 | 22 | main() async { 23 | // 'await' will suspend execution of the function until the 24 | // future completes: 25 | var gregsLastName = await loadLastName('greg'); 26 | var stevesLastName = await loadLastName2('steve'); 27 | 28 | print('greg $gregsLastName'); 29 | print('steve $stevesLastName'); 30 | } 31 | -------------------------------------------------------------------------------- /web/examples/async_await/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Async / Await 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/async_await/async_await.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart async_await.dart 13 | greg gregson 14 | steve steveson 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/async_star/async_star.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | main() async { 4 | await for (String msg in printNumbersDownAsync(5)) { 5 | print(msg); 6 | } 7 | } 8 | 9 | Stream printNumbersDownAsync(int n) async* { 10 | int k = n; 11 | while (k >= 0) { 12 | yield await loadMessageForNumber(k--); 13 | } 14 | } 15 | 16 | Future loadMessageForNumber(int i) async { 17 | await new Future.delayed(new Duration(milliseconds: 50)); 18 | if (i % 2 == 0) { 19 | return '$i is even'; 20 | } else { 21 | return '$i is odd'; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /web/examples/async_star/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Async* 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/async_star/async_star.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart async_star.dart 13 | 5 is odd 14 | 4 is even 15 | 3 is odd 16 | 2 is even 17 | 1 is odd 18 | 0 is even 19 | ``` 20 | -------------------------------------------------------------------------------- /web/examples/await_for/await_for.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | main() async { 4 | await for (int i in numbersDownFrom(5)) { 5 | print('$i bottles of beer'); 6 | } 7 | } 8 | 9 | Stream numbersDownFrom(int n) async* { 10 | while (n >= 0) { 11 | await new Future.delayed(new Duration(milliseconds: 100)); 12 | yield n--; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /web/examples/await_for/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Await For 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/await_for/await_for.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart await_for.dart 13 | 5 bottles of beer 14 | 4 bottles of beer 15 | 3 bottles of beer 16 | 2 bottles of beer 17 | 1 bottles of beer 18 | 0 bottles of beer 19 | ``` 20 | -------------------------------------------------------------------------------- /web/examples/classes/classes.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | class Position { 4 | // properties 5 | int x; 6 | int y; 7 | 8 | // methods 9 | double distanceTo(Position other) { 10 | var dx = other.x - x; 11 | var dy = other.y - y; 12 | return sqrt(dx * dx + dy * dy); 13 | } 14 | } 15 | 16 | main() { 17 | var origin = new Position() 18 | ..x = 0 19 | ..y = 0; 20 | 21 | var p = new Position() 22 | ..x = -5 23 | ..y = 6; 24 | 25 | print(origin.distanceTo(p)); 26 | } 27 | -------------------------------------------------------------------------------- /web/examples/classes/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Classes 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/classes/classes.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart classes.dart 13 | 7.810249675906654 14 | ``` 15 | -------------------------------------------------------------------------------- /web/examples/comments/comments.dart: -------------------------------------------------------------------------------- 1 | /// Represents a two-dimensional position 2 | /// has [x] and [y] properties 3 | /// 4 | /// example code can be defined using a four-space indent: 5 | /// 6 | /// var p = new Position(); 7 | /// 8 | class Position { 9 | /* 10 | multi-line comments 11 | */ 12 | int x; 13 | 14 | // A regular comment 15 | int y; 16 | } 17 | 18 | main() { 19 | print(new Position().runtimeType); 20 | } 21 | -------------------------------------------------------------------------------- /web/examples/comments/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Comments 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 | Dartdoc parses comments starting with `///`. 7 | Multiple-line comments and single-line comments 8 | use `/* */` and `//`, respectively 9 | 10 |
11 | {{> web/examples/comments/comments.dart}}
12 | 
13 | 
14 | 15 | ```bash 16 | $ dart comments.dart 17 | Position 18 | ``` 19 | -------------------------------------------------------------------------------- /web/examples/const/const.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | // compile-time constants are defined using 'const' 4 | const name = "greg"; 5 | 6 | // Objects can also be declared at compile-time 7 | const Rectangle bounds = const Rectangle(0, 0, 5, 5); 8 | 9 | main() { 10 | print(name); 11 | print(bounds); 12 | } 13 | -------------------------------------------------------------------------------- /web/examples/const/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Constants 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 | In dart, compile-time constants can be created as long 7 | as the object's deep structure can be determined at compile time. 8 | 9 |
10 | {{> web/examples/const/const.dart}}
11 | 
12 | 
13 | 14 | ```bash 15 | $ dart const.dart 16 | greg 17 | Rectangle (0, 0) 5 x 5 18 | ``` 19 | -------------------------------------------------------------------------------- /web/examples/constructors/constructors.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | class Position { 4 | int x; 5 | int y; 6 | 7 | // A simple constructor 8 | Position(this.x, this.y); 9 | 10 | // Additional constructors can be defined using named constructors 11 | Position.atOrigin() { 12 | x = 0; 13 | y = 0; 14 | } 15 | 16 | // Factory constructors 17 | factory Position.fromMap(Map m) { 18 | return new Position(m['x'], m['y']); 19 | } 20 | 21 | String toString() => "[$x, $y]"; 22 | } 23 | 24 | main() { 25 | print(new Position(30, 40)); 26 | print(new Position.atOrigin()); 27 | print(new Position.fromMap({'x': 4, 'y': 100})); 28 | } 29 | -------------------------------------------------------------------------------- /web/examples/constructors/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Constructors 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/constructors/constructors.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart constructors.dart 13 | [30, 40] 14 | [0, 0] 15 | [4, 100] 16 | ``` 17 | -------------------------------------------------------------------------------- /web/examples/exceptions/exceptions.dart: -------------------------------------------------------------------------------- 1 | // 2 | class FoodSpoiledError extends StateError { 3 | FoodSpoiledError(String msg) : super(msg); 4 | } 5 | 6 | class Potato { 7 | int age; 8 | 9 | Potato(this.age); 10 | 11 | String peel() { 12 | if (age > 4) { 13 | throw new FoodSpoiledError('your potato is spoiled'); 14 | } 15 | return "peeled"; 16 | } 17 | } 18 | 19 | main() { 20 | var p = new Potato(7); 21 | 22 | try { 23 | p.peel(); 24 | } on FoodSpoiledError catch(_) { 25 | print("nope nope nope"); 26 | } 27 | 28 | // any non-null object can be thrown: 29 | try { 30 | throw("potato"); 31 | } catch(_) { 32 | print("caught a flying potato"); 33 | } 34 | 35 | // exceptions halt excecution 36 | p.peel(); 37 | print('not reached'); 38 | } 39 | -------------------------------------------------------------------------------- /web/examples/exceptions/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Exceptions 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/exceptions/exceptions.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart exceptions.dart 13 | nope nope nope 14 | caught a flying potato 15 | Unhandled exception: 16 | Bad state: your potato is spoiled 17 | #0 Potato.peel (file:///exceptions.dart:13:7) 18 | #1 main (file:///exceptions.dart:36:5) 19 | #2 _startIsolate. (dart:isolate-patch/isolate_patch.dart:261) 20 | #3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148) 21 | ``` 22 | -------------------------------------------------------------------------------- /web/examples/final/final.dart: -------------------------------------------------------------------------------- 1 | 2 | main() { 3 | 4 | // final variables are single-assignment: 5 | final foo = "hello"; 6 | 7 | try { 8 | foo = 'goodbye'; // runtime error; already assigned 9 | } catch(e) { 10 | print('error'); 11 | } 12 | 13 | var pos = new Position(4); 14 | 15 | try { 16 | pos.x = 100; // runtime error 17 | } catch(e) { 18 | print('error'); 19 | } 20 | } 21 | 22 | class Position { 23 | final int x; 24 | final int y; 25 | Position(this.x) : y = 0; 26 | } 27 | -------------------------------------------------------------------------------- /web/examples/final/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Final 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 | Final objects are immutable 7 | 8 |
 9 | {{> web/examples/final/final.dart}}
10 | 
11 | 
12 | 13 | ```bash 14 | $ dart final.dart 15 | error 16 | error 17 | ``` 18 | -------------------------------------------------------------------------------- /web/examples/for/for1.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | // A standard for loop 3 | for (var i = 0; i < 3; i++) { 4 | print(i); 5 | } 6 | 7 | // 'for-in' can be used on any class that implements Iterable 8 | var collection = [3, 4, 5]; 9 | for (var x in collection) { 10 | print(x); 11 | } 12 | 13 | // Closures will capture the value of the index (Dart is lexically scoped) 14 | var callbacks = []; 15 | for (var i = 6; i < 8; i++) { 16 | callbacks.add(() => print(i)); 17 | } 18 | callbacks.forEach((c) => c()); // invoke each callback 19 | } 20 | -------------------------------------------------------------------------------- /web/examples/for/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: For 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/for/for1.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart for.dart 13 | 0 14 | 1 15 | 2 16 | 3 17 | 4 18 | 5 19 | 6 20 | 7 21 | ``` 22 | -------------------------------------------------------------------------------- /web/examples/functions/functions.dart: -------------------------------------------------------------------------------- 1 | // A simple function definition 2 | yell(str) => str.toUpperCase(); 3 | 4 | // Functions can have type annotations 5 | List lines(String str) { 6 | return str.split('\n'); 7 | } 8 | 9 | main() { 10 | var poemLines = lines(poem); 11 | print(yell(poemLines.first)); 12 | 13 | // functions are first-class 14 | var whisper = (String str) => str.toLowerCase(); 15 | print(poemLines.map(whisper).last); 16 | } 17 | 18 | const poem = ''' 19 | The wren 20 | Earns his living 21 | Noiselessly.'''; 22 | -------------------------------------------------------------------------------- /web/examples/functions/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Functions 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/functions/functions.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart functions.dart 13 | THE WREN 14 | noiselessly. 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/futures/futures.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | main() { 4 | 5 | // Passing a callback to then() will invoke 6 | // that callback when the future completes 7 | onReady.then((String status) { 8 | print(status); 9 | }); 10 | 11 | // Futures can be chained: 12 | onReady 13 | .then(print) 14 | .then((_) => print('done!')); 15 | 16 | // Futures can throw errors: 17 | onReady.catchError(() { 18 | print('error!'); 19 | }); 20 | } 21 | 22 | Future get onReady { 23 | var dur = new Duration(seconds: 1); 24 | var oneSecond = new Future.delayed(dur); 25 | 26 | // then() returns a new future that completes 27 | // with the value of the callback. 28 | return oneSecond.then((_) { 29 | return 'loaded!'; 30 | }); 31 | } -------------------------------------------------------------------------------- /web/examples/futures/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Futures 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/futures/futures.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart futures.dart 13 | loaded! 14 | loaded! 15 | done! 16 | ``` 17 | -------------------------------------------------------------------------------- /web/examples/generators/generators.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | evenNumbersDownFrom(7).forEach(print); 3 | } 4 | 5 | // sync* functions return an iterable 6 | Iterable evenNumbersDownFrom(int n) sync* { 7 | // the body isn't executed until an iterator invokes moveNext() 8 | int k = n; 9 | while (k >= 0) { 10 | if (k % 2 == 0) { 11 | // 'yield' suspends the function 12 | yield k; 13 | } 14 | k--; 15 | } 16 | 17 | // when the end of the function is executed, 18 | // there are no more values in the Iterable, and 19 | // moveNext() returns false to the caller 20 | } 21 | -------------------------------------------------------------------------------- /web/examples/generators/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Generators 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 | ```dart 7 | {{> web/examples/generators/generators.dart}} 8 | ``` 9 | 10 | ```bash 11 | $ dart generators.dart 12 | 6 13 | 4 14 | 2 15 | 0 16 | ``` 17 | -------------------------------------------------------------------------------- /web/examples/getters_setters/getters_setters.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | class Position { 4 | int _x; 5 | int _y; 6 | 7 | Position(this._x, this._y); 8 | 9 | double get rad => atan2(_y, _x); 10 | 11 | void set x(int val) { 12 | _x = val; 13 | } 14 | } 15 | 16 | main() { 17 | var p = new Position(2, 3); 18 | p.x = 10; 19 | print('x: ${p._x} y: ${p._y}'); 20 | print('rad: ${p.rad}'); 21 | } 22 | -------------------------------------------------------------------------------- /web/examples/getters_setters/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Getters and Setters 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/getters_setters/getters_setters.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ getters_setters.dart 13 | x: 10 y: 3 14 | rad: 0.2914567944778671 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/hello_world/hello_world.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | print('Hello, World!'); 3 | } 4 | -------------------------------------------------------------------------------- /web/examples/hello_world/hello_world2.dart: -------------------------------------------------------------------------------- 1 | main() => print('Hello, World!'); 2 | -------------------------------------------------------------------------------- /web/examples/hello_world/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Hello World 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
{{> web/examples/hello_world/hello_world.dart}}
7 | 8 | You can also use arrow function syntax: 9 | 10 |
{{> web/examples/hello_world/hello_world2.dart}}
11 | 12 | ```bash 13 | $ dart hello_world.dart 14 | Hello, World! 15 | ``` 16 | 17 | [Edit on DartPad](https://dartpad.dartlang.org/?source=c4c2f4d1-ecb7-4f12-9dec-12f1294cdcc0) 18 | -------------------------------------------------------------------------------- /web/examples/http_request/http_request.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'package:http/http.dart' as http; 3 | 4 | main() async { 5 | 6 | // The http package can be used to make HTTP requests using dart:io 7 | // or from the browser via XMLHttpRequests 8 | var query = 'dartlang'; 9 | var requestUrl = 'http://hn.algolia.com/api/v1/search?query=$query'; 10 | var response = await http.get(requestUrl); 11 | 12 | // decode the reponse into a Map 13 | var jsonResponse = json.decode(response.body); 14 | 15 | // print a link to the article 16 | var firstResult = jsonResponse['hits'][0]; 17 | var firstTitle = firstResult['title']; 18 | var firstLink = firstResult['url']; 19 | print('$firstTitle : $firstLink'); 20 | } 21 | -------------------------------------------------------------------------------- /web/examples/http_request/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: HTTP Requests 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
{{> web/examples/http_request/http_request.dart}}
7 | 8 | ```bash 9 | $ dart http_request.dart 10 | Dart Lang 1.2 Released : https://www.dartlang.org/ 11 | ``` 12 | -------------------------------------------------------------------------------- /web/examples/http_server/http_server.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | main() async { 4 | var server = await HttpServer.bind(InternetAddress.ANY_IP_V4, 8777); 5 | print('serving on port ${server.port}'); 6 | 7 | // HttpServer extends Stream, so using await-for 8 | // will run the loop body when a request is added to the stream. 9 | await for (HttpRequest req in server) { 10 | // resposne 11 | req.response 12 | ..write("welcome to my dart server") 13 | ..close(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /web/examples/http_server/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Http Server 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/http_server/http_server.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart http_server.dart 13 | serving on port 8777 14 | ``` 15 | 16 | opening `localhost:8777`: 17 | 18 | ``` 19 | welcome to my dart server 20 | ``` 21 | -------------------------------------------------------------------------------- /web/examples/ifelse/ifelse.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | 3 | if (7 % 2 == 0) { 4 | print('7 is even'); 5 | } else { 6 | print('7 is odd'); 7 | } 8 | 9 | if (8 % 4 == 0) { 10 | print('8 is divisble by 4'); 11 | } 12 | 13 | // ternary operators 14 | var isAlive = true; 15 | var monday = isAlive ? 'doctor' : null; 16 | print('monday appointment: $monday'); 17 | } 18 | -------------------------------------------------------------------------------- /web/examples/ifelse/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: If Else 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/ifelse/ifelse.dart}}
 8 | 
 9 | 
10 | 11 | ``` 12 | $ dart ifelse.dart 13 | 7 is odd 14 | 8 is divisble by 4 15 | monday appointment: doctor 16 | ``` 17 | -------------------------------------------------------------------------------- /web/examples/inheritance/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Inheritance 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/inheritance/inheritance.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart inheritance.dart 13 | Barry has been released: bark! 14 | Pikachu has been released: pika! 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/inheritance/inheritance.dart: -------------------------------------------------------------------------------- 1 | /// Abstract classes can't be instantiated, 2 | /// but can contain some implementation. 3 | abstract class Animal { 4 | String name; 5 | Animal(this.name); 6 | String get noise; 7 | } 8 | 9 | /// Classes can be extended to share functionality 10 | class Dog extends Animal { 11 | Dog(String name) : super(name); 12 | String get noise => 'bark!'; 13 | } 14 | 15 | /// Classes can implement other classes if they 16 | /// define all of the fields 17 | class Pikachu implements Animal { 18 | String name = 'Pikachu'; 19 | String get noise => 'pika!'; 20 | } 21 | 22 | void releaseAnimals(Iterable animals) { 23 | animals.forEach((a) => print('${a.name} has been released: ${a.noise}')); 24 | } 25 | 26 | main() { 27 | var barry = new Dog('Barry'); 28 | var pika = new Pikachu(); 29 | releaseAnimals([barry, pika]); 30 | } 31 | -------------------------------------------------------------------------------- /web/examples/initializer_lists/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Initializer Lists 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/initializer_lists/initializer_lists.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ initializer_lists.dart 13 | x: 2 y: 3 14 | rad: 0.5880026035475675 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/initializer_lists/initializer_lists.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | class Position { 4 | final int x; 5 | final int y; 6 | final double rad; 7 | 8 | // An initializer list allows 9 | // fields to be defined before the constructor body. 10 | // This is required for final fields. 11 | Position(int x, int y) 12 | : this.x = x, 13 | this.y = y, 14 | rad = atan2(y, x); 15 | } 16 | 17 | main() { 18 | var p = new Position(2, 3); 19 | print('x: ${p.x} y: ${p.y}'); 20 | print('rad: ${p.rad}'); 21 | } 22 | -------------------------------------------------------------------------------- /web/examples/isolates/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Isolates 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/isolates/isolates.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ isolates.dart 13 | received foo 14 | received bar 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/isolates/isolates.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:isolate'; 3 | 4 | main() async { 5 | var receivePort = new ReceivePort(); 6 | await Isolate.spawn(echo, receivePort.sendPort); 7 | 8 | // The 'echo' isolate sends it's SendPort as the first message 9 | var sendPort = await receivePort.first; 10 | 11 | var msg = await sendReceive(sendPort, "foo"); 12 | print('received $msg'); 13 | msg = await sendReceive(sendPort, "bar"); 14 | print('received $msg'); 15 | } 16 | 17 | // the entry point for the isolate 18 | echo(SendPort sendPort) async { 19 | // Open the ReceivePort for incoming messages. 20 | var port = new ReceivePort(); 21 | 22 | // Notify any other isolates what port this isolate listens to. 23 | sendPort.send(port.sendPort); 24 | 25 | await for (var msg in port) { 26 | var data = msg[0]; 27 | SendPort replyTo = msg[1]; 28 | replyTo.send(data); 29 | if (data == "bar") port.close(); 30 | } 31 | } 32 | 33 | /// sends a message on a port, receives the response, 34 | /// and returns the message 35 | Future sendReceive(SendPort port, msg) { 36 | ReceivePort response = new ReceivePort(); 37 | port.send([msg, response.sendPort]); 38 | return response.first; 39 | } -------------------------------------------------------------------------------- /web/examples/iterables/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Iterables 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/iterables/iterables.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart iterables.dart 13 | greg 14 | steve 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/iterables/iterables.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | // Iterable is implemented by LinkedList,List, ListQueue, Queue, Runes, 3 | // Set, and more. 4 | var set = new Set()..add('greg')..add('steve'); 5 | 6 | for (var name in set) { 7 | print(name); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /web/examples/iterators/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Iterators 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/iterators/iterators.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart iterators.dart 13 | 1 14 | 5 15 | 10 16 | 0 17 | 2 18 | 4 19 | ``` 20 | -------------------------------------------------------------------------------- /web/examples/iterators/iterators.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | var iter = [1,5,10].iterator; 3 | while(iter.moveNext()) { 4 | print(iter.current); 5 | } 6 | 7 | var iterable = new Iterable.generate(3); 8 | var iter2 = iterable.map((n) => n*2).iterator; 9 | while(iter2.moveNext()) { 10 | print(iter2.current); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /web/examples/lexical_scope/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Lexical Scope 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 | Dart is a lexically scoped language. 7 | Loops that declare their variable will have a new version of that variable for each iteration. 8 | 9 |
10 | {{> web/examples/lexical_scope/lexical_scope.dart}}
11 | 
12 | 
13 | 14 | ```bash 15 | $ dart lexical_scope.dart 16 | 0 17 | 1 18 | 2 19 | ``` 20 | 21 | Compared to javascript: 22 | 23 |
24 | {{> web/examples/lexical_scope/lexical_scope.js}}
25 | 
26 | 
27 | 28 | ```bash 29 | $ node lexical_scope.js 30 | 3 31 | 3 32 | 3 33 | ``` 34 | -------------------------------------------------------------------------------- /web/examples/lexical_scope/lexical_scope.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | var functions = []; 3 | 4 | for (var i = 0; i < 3; i++) { 5 | functions.add(() => i); 6 | } 7 | 8 | functions.forEach((fn) => print(fn())); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /web/examples/lexical_scope/lexical_scope.js: -------------------------------------------------------------------------------- 1 | var functions = []; 2 | 3 | for (var i = 0; i < 3; i++) { 4 | functions[i] = function() { return i }; 5 | } 6 | 7 | functions.forEach(function (fn) { console.log(fn())}); -------------------------------------------------------------------------------- /web/examples/libraries/app.dart: -------------------------------------------------------------------------------- 1 | // app.dart 2 | 3 | library app; 4 | 5 | import 'utils.dart'; 6 | 7 | main() { 8 | print(shout('Welcome')); 9 | print(whisper('Welcome')); 10 | } 11 | -------------------------------------------------------------------------------- /web/examples/libraries/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Libraries 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 | libraries are imported using the `import` keyword: 7 | 8 |
 9 | {{> web/examples/libraries/app.dart}}
10 | 
11 | 
12 | 13 | libraries can be split into *parts* using the `part` and `part of` syntax: 14 | 15 |
16 | {{> web/examples/libraries/utils.dart}}
17 | 
18 | 
19 | 20 |
21 | {{> web/examples/libraries/whisper.dart}}
22 | 
23 | 
24 | 25 | ```bash 26 | $ app.dart 27 | WELCOME!!! 28 | welcome... 29 | ``` 30 | -------------------------------------------------------------------------------- /web/examples/libraries/utils.dart: -------------------------------------------------------------------------------- 1 | // utils.dart 2 | 3 | library utils; 4 | 5 | part 'whisper.dart'; 6 | 7 | String shout(String inp) => inp.toUpperCase() + '!!!'; 8 | -------------------------------------------------------------------------------- /web/examples/libraries/whisper.dart: -------------------------------------------------------------------------------- 1 | // whisper.dart 2 | 3 | part of utils; 4 | 5 | String whisper(String inp) => inp.toLowerCase() + '...'; 6 | -------------------------------------------------------------------------------- /web/examples/list/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: List 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/list/list.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart list.dart 13 | [a, b, c] 14 | [grow, able] 15 | [also, growable, 42] 16 | error 17 | ``` 18 | -------------------------------------------------------------------------------- /web/examples/list/list.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | 3 | // Specifying the length creates a fixed-length list. 4 | var list = new List(3); 5 | list[0] = 'a'; 6 | list[1] = 'b'; 7 | list[2] = 'c'; 8 | print(list); 9 | 10 | // Leaving out the length creates a growable list. 11 | var growable = new List(); 12 | growable.addAll(['grow', 'able']); 13 | print(growable); 14 | 15 | // Lists can be defined using bracket literals. 16 | // 17 | var list2 = ['also', 'growable']; 18 | list2.add(42); 19 | print(list2); 20 | 21 | // modifying growable lists during iteration can cause ConcurrentModificationErrors 22 | var list3 = [47, 3, 25]; 23 | try { 24 | for (var item in list3) { 25 | if (item < 10) { 26 | list3.remove(item); 27 | } 28 | } 29 | } catch(e) { 30 | print('error'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /web/examples/map/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Map 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/map/map.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart map.dart 13 | {blue: false, red: true} 14 | {square: false, triangle: true} 15 | square 16 | triangle 17 | false 18 | true 19 | ``` 20 | -------------------------------------------------------------------------------- /web/examples/map/map.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | 3 | // adding keys 4 | var colors = new Map(); 5 | colors['blue'] = false; 6 | colors['red'] = true; 7 | print(colors); 8 | 9 | // curly bracket literals can also be used: 10 | var shapes = { 11 | 'square': false, 12 | 'triangle': true 13 | }; 14 | print(shapes); 15 | 16 | // keys and values can be iterated. 17 | // HashMap iterates in arbitrary order, while LinkedHashMap, and SplayTreeMap 18 | // iterate in the order they were inserted into the map. 19 | for (var key in shapes.keys) print(key); 20 | for (var value in shapes.values) print(value); 21 | } 22 | -------------------------------------------------------------------------------- /web/examples/microtasks/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Microtasks 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/microtasks/microtasks.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart microtasks.dart 13 | hello 14 | there 15 | beautiful 16 | world 17 | ``` 18 | -------------------------------------------------------------------------------- /web/examples/microtasks/microtasks.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | main() { 4 | 5 | // Future() schedules a task on the event queue: 6 | new Future(() => print('world')); 7 | print('hello'); 8 | 9 | // scheduleMicrotask() will add the task to the microtask queue: 10 | // Tasks on the microtask queue are executed before the next 11 | // run-loop on the event queue. 12 | scheduleMicrotask(() => print('beautiful')); 13 | 14 | print('there'); 15 | } 16 | -------------------------------------------------------------------------------- /web/examples/mixins/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Mixins 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/mixins/mixins.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart mixins.dart 13 | 7.0710678118654755 14 | 100 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/mixins/mixins.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | class Position { 4 | int x; 5 | int y; 6 | 7 | double distanceTo(Position other) { 8 | var dx = other.x - x; 9 | var dy = other.y - y; 10 | return sqrt(dx * dx + dy * dy); 11 | } 12 | } 13 | 14 | class Square { 15 | int width; 16 | int height; 17 | 18 | int get area => width * height; 19 | } 20 | 21 | // Classes can be mixed in using 'with' 22 | class SquareView extends Square with Position {} 23 | 24 | main() { 25 | var origin = new Position() 26 | ..x = 0 27 | ..y = 0; 28 | 29 | var square = new SquareView() 30 | ..x = 5 31 | ..y = 5 32 | ..width = 10 33 | ..height = 10; 34 | 35 | print(square.distanceTo(origin)); 36 | print(square.area); 37 | } 38 | -------------------------------------------------------------------------------- /web/examples/null_aware/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Null-Aware Operators 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/null_aware/nullaware1.dart}}
 8 | 
 9 | 
10 | 11 | ``` 12 | $ dart nullaware.dart 13 | next appoinment: doctor 14 | next appointment: doctor 15 | length: null 16 | ``` 17 | -------------------------------------------------------------------------------- /web/examples/null_aware/nullaware1.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | 3 | // The ?? operator returns the first expression IFF it is not null 4 | var monday = 'doctor'; 5 | var tuesday; 6 | var next = tuesday ?? monday; 7 | print('next appointment: $next'); 8 | 9 | // the ??= operator assigns a value IFF it is not null 10 | var wednesday; 11 | next ??= wednesday; 12 | print('next appointment: $next'); 13 | 14 | // the ? operator calls a function IFF the object is not null 15 | String thursday; 16 | var length = thursday?.length; 17 | print('length: $length'); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /web/examples/optional_params/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Optional Parameters 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/optional_params/optional_params.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart optional_params.dart 13 | HELLO, WORLD 14 | HELLO, WORLD!!! 15 | hello, world... 16 | ``` 17 | -------------------------------------------------------------------------------- /web/examples/optional_params/optional_params.dart: -------------------------------------------------------------------------------- 1 | // an ordered optional parameter 2 | String yell(String str, [bool exclaim = false]) { 3 | var result = str.toUpperCase(); 4 | if (exclaim) result = result + '!!!'; 5 | return result; 6 | } 7 | 8 | // named optional parameters 9 | String whisper(String str, {bool mysteriously: false}) { 10 | var result = str.toLowerCase(); 11 | if (mysteriously) result = result + '...'; 12 | return result; 13 | } 14 | 15 | 16 | main() { 17 | print(yell('Hello, World')); 18 | print(yell('Hello, World', true)); 19 | print(whisper('Hello, World', mysteriously: true)); 20 | } 21 | -------------------------------------------------------------------------------- /web/examples/pub/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Pub 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 | Pub is the package manager for Dart. 7 | 8 | A typical package has this file structure: 9 | 10 | ``` 11 | cool_package/ 12 | bin/ 13 | ice 14 | lib/ 15 | sodas.dart 16 | src/ 17 | pepsi.dart 18 | coke.dart 19 | example/ 20 | soda_example.dart 21 | web/ 22 | cool_app.dart 23 | index.html 24 | style.css 25 | pubspec.yaml 26 | README.md 27 | ``` 28 | 29 | ```yaml 30 | # pubspec.yaml 31 | 32 | name: cool_package # use separate package names with underscores 33 | version: 1.2.3 # use semver 34 | description: > 35 | A really cool package that allows you to 36 | reticulate your splines and transmogrify 37 | your unidirectional dataflow. 38 | author: John Ryan 39 | homepage: johnpryan.github.io 40 | environment: 41 | sdk: ">=0.12.0" 42 | documentation: http://docs.coolpackagedartlang.com 43 | dependencies: 44 | yaml: ^2.1.0 45 | frappe: ^0.4.0 46 | dev_dependencies: 47 | test: ^0.12.0 48 | dependency_overrides: 49 | stream_transformers: 0.2.0 50 | yaml: 51 | path: ../yaml 52 | ``` 53 | 54 | `dependency_override`s force all packages 55 | in the dependency graph to use a specific version 56 | (since only one version of a package is allowed.) 57 | 58 | `path:` dependencies are convenient if multiple packages 59 | are being developed on a local machine. 60 | 61 | For details, see [pub package layout conventions](https://www.dartlang.org/tools/pub/package-layout.html). 62 | -------------------------------------------------------------------------------- /web/examples/pub/pubspec.yaml: -------------------------------------------------------------------------------- 1 | # pubspec.yaml 2 | 3 | name: cool_package # use separate package names with underscores 4 | version: 1.2.3 # use semver 5 | description: > 6 | A really cool package that allows you to 7 | reticulate your splines and transmogrify 8 | your unidirectional dataflow. 9 | author: John Ryan 10 | homepage: johnpryan.github.io 11 | environment: 12 | sdk: ">=0.12.0" 13 | documentation: http://docs.coolpackagedartlang.com 14 | dependencies: 15 | yaml: ^2.1.0 16 | frappe: ^0.4.0 17 | dev_dependencies: 18 | test: ^0.12.0 19 | 20 | # Overridden dependencies force all packages 21 | # in the dependency graph to use a specific version 22 | # (since only one version of a package is allowed) 23 | dependency_overrides: 24 | stream_transformers: 0.2.0 25 | 26 | # If you are developing a package (yaml) locally, 27 | # it's convenient to override using a path depencency 28 | yaml: 29 | path: ../yaml 30 | 31 | -------------------------------------------------------------------------------- /web/examples/queue/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Queue 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/queue/queue.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart queue.dart 13 | (300, 200) 14 | {100, 500} 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/queue/queue.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | main() { 4 | // Queues are optimized for adding to the head or tail 5 | // Items cannot be accessed by their index. 6 | var q = new Queue.from([300, 200, 100, 500]); 7 | 8 | // Queues implement Iterable: 9 | print(q.takeWhile((i) => i > 100)); 10 | 11 | // Consuming a queue 12 | while(q.first > 100) { 13 | q.removeFirst(); 14 | } 15 | print(q); 16 | } 17 | -------------------------------------------------------------------------------- /web/examples/set/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Set 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/set/set.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart set.dart 13 | has gold? true 14 | has platinum? false 15 | {gold, silver, bronze, breakfast, lunch, dinner} 16 | gold 17 | null 18 | {gold, silver, bronze} 19 | ``` 20 | -------------------------------------------------------------------------------- /web/examples/set/set.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | var medals = new Set(); 3 | medals.add("gold"); 4 | medals.add("silver"); 5 | medals.add("bronze"); 6 | 7 | // HashSets use the equality operator (==) to determine 8 | // if it already contains an item 9 | medals.add("gold"); 10 | 11 | print('has gold? ${medals.contains("gold")}'); 12 | print('has platinum? ${medals.contains("platinum")}'); 13 | 14 | // Sets can be constructed from Iterables 15 | var meals = new Set.from(['breakfast', 'lunch', 'dinner']); 16 | 17 | // Some built-in features: 18 | print(medals.union(meals)); 19 | print(medals.lookup("gold")); 20 | print(medals.lookup("platinum")); 21 | print(medals.difference(meals)); 22 | } 23 | -------------------------------------------------------------------------------- /web/examples/static/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Static 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 | Static members (functions or properties) are available on 7 | the class itself, instead of on an instance of that class. 8 | 9 |
10 | {{> web/examples/static/static.dart}}
11 | 
12 | 
13 | 14 | ```bash 15 | $ dart static.dart 16 | 100 17 | 200 18 | ``` 19 | -------------------------------------------------------------------------------- /web/examples/static/static.dart: -------------------------------------------------------------------------------- 1 | class Position { 2 | // a static function 3 | static int get maxX => 100; 4 | 5 | // a static property 6 | static int maxY = 200; 7 | } 8 | 9 | main() { 10 | print(Position.maxX); 11 | print(Position.maxY); 12 | } 13 | -------------------------------------------------------------------------------- /web/examples/streams/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Streams 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/streams/streams.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart streams.dart 13 | s1: 1 14 | s3: 2 15 | s4: 1 16 | s4: 1 17 | s1: 3 18 | s3: 4 19 | s4: 2 20 | s4: 2 21 | s1: 5 22 | s3: 10 23 | s2: tick! 24 | s2: tick! 25 | s2: tick! 26 | ``` 27 | -------------------------------------------------------------------------------- /web/examples/streams/streams.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | main() { 4 | // creates a single subscription stream 5 | new Stream.fromIterable([1, 3, 5]).listen((i) { 6 | print('s1: $i'); 7 | }); 8 | 9 | // New streams can created from other streams, using 10 | // using methods like where(), map(), expand(), take(), or skip() 11 | new Stream.periodic(new Duration(milliseconds: 300)) 12 | .take(3) 13 | .listen((_) => print('s2: tick!')); 14 | 15 | new Stream.fromIterable([1, 2, 5]).map((n) => n * 2).listen((n) => print('s3: $n')); 16 | 17 | // Broadcast streams can be listened to by multiple consumers. 18 | var sc = new StreamController.broadcast(); 19 | var broadcastStream = sc.stream; 20 | broadcastStream.listen((v) => print('s4: $v')); 21 | broadcastStream.listen((v) => print('s4: $v')); 22 | sc.add(1); 23 | sc.add(2); 24 | } 25 | -------------------------------------------------------------------------------- /web/examples/switch/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Switch 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/switch/switch.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart switch.dart 13 | L-shape 14 | diagonal 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/switch/switch.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | // a typical switch statement 3 | var piece = 'knight'; 4 | switch(piece) { 5 | case 'bishop': 6 | print('diagonal'); 7 | break; 8 | case 'knight': 9 | print('L-shape'); 10 | break; 11 | default: 12 | print('checkmate'); 13 | } 14 | 15 | // cases can only fall through if they are empty: 16 | piece = 'queen'; 17 | switch(piece) { 18 | case 'queen': 19 | case 'bishop': 20 | print('diagonal'); 21 | break; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /web/examples/typedef/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Function Types 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/typedef/typedef.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart typedef.dart 13 | true 14 | false 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/typedef/typedef.dart: -------------------------------------------------------------------------------- 1 | typedef bool Validator(int n); 2 | 3 | bool positive(int n) => n >= 0; 4 | bool lessThan100(int n) => n < 100; 5 | 6 | bool bothValid(int n, Validator v1, Validator v2) { 7 | return v1(n) && v2(n); 8 | } 9 | 10 | main() { 11 | Validator both = (int n) => bothValid(n, positive, lessThan100); 12 | print('${both(5)}'); 13 | print('${both(1000)}'); 14 | } 15 | -------------------------------------------------------------------------------- /web/examples/unused_variables/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Unused Variables 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/unused_variables/unnamed_variables.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dartanalyzer web/examples/unnamed_parameters/unnamed_parameters.dart 13 | [hint] The value of the local variable 'i' is not used (unnamed_parameters.dart, line 2, col 12) 14 | 1 hint found. 15 | ``` 16 | -------------------------------------------------------------------------------- /web/examples/unused_variables/unnamed_variables.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | for (var i in new Iterable.generate(1)) { 3 | print('not using "i"'); 4 | } 5 | 6 | // using an underscore silences "local variable is not used" 7 | // warnings when running dartanalyzer 8 | for (var _ in new Iterable.generate(1)) { 9 | print('no warnings'); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /web/examples/values/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Values 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/values/values1.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart values.dart 13 | 1+1=2 14 | 7.0/3.0 =2.3333333333333335 15 | false 16 | true 17 | false 18 | ``` 19 | -------------------------------------------------------------------------------- /web/examples/values/values1.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | // Strings can be appended using + 3 | print("dart" + "lang"); 4 | 5 | // Integers and Floats 6 | print("1+1=${1+1}"); 7 | print("7.0/3.0 =${7.0/3.0}"); 8 | 9 | // Booleans 10 | print(true && false); 11 | print(false || true); 12 | print(!true); 13 | } 14 | -------------------------------------------------------------------------------- /web/examples/variables/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Variables 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/variables/variables1.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart variables.dart 13 | initial 14 | 42 15 | 99 16 | 44.0 17 | ``` -------------------------------------------------------------------------------- /web/examples/variables/variables1.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | // 'var' declares a variable. dartanalyzer infers the type. 3 | var a = "initial"; 4 | print(a); 5 | 6 | // The type can also be declared: 7 | num b = 42; 8 | print(b); 9 | 10 | // final variables cannot be changed once declared 11 | final num c = 99; 12 | print(c); 13 | 14 | // const variables are compile-time constants 15 | const double d = 44.00; 16 | print(d); 17 | } 18 | -------------------------------------------------------------------------------- /web/examples/while/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: While 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/while/while.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart while.dart 13 | while 1 14 | while 2 15 | dowhile 0 16 | dowhile 1 17 | dowhile 2 18 | ``` 19 | -------------------------------------------------------------------------------- /web/examples/while/while.dart: -------------------------------------------------------------------------------- 1 | main() { 2 | var i = 0; 3 | 4 | // while conditions are evaluated before the loop 5 | while(i++ < 2) { 6 | print("while $i"); 7 | } 8 | 9 | var j = 0; 10 | 11 | // do-while conditions are evaluated after the loop 12 | do { 13 | print("dowhile $j"); 14 | } while (j++ < 2); 15 | } 16 | -------------------------------------------------------------------------------- /web/examples/yield_star/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Yield* 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/yield_star/yield_each.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart yield_each.dart 13 | 5 bottles of beer 14 | 4 bottles of beer 15 | 3 bottles of beer 16 | 2 bottles of beer 17 | 1 bottles of beer 18 | 0 bottles of beer 19 | ``` 20 | -------------------------------------------------------------------------------- /web/examples/yield_star/yield_each.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | main() async { 4 | await for (int i in numbersDownFrom(5)) { 5 | print('$i bottles of beer'); 6 | } 7 | } 8 | 9 | Stream numbersDownFrom(int n) async* { 10 | if (n >= 0) { 11 | await new Future.delayed(new Duration(milliseconds: 100)); 12 | yield n; 13 | yield* numbersDownFrom(n - 1); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /web/examples/zones/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Zones 3 | template: web/templates/_example.mustache 4 | --- 5 | 6 |
 7 | {{> web/examples/zomes/zones.dart}}
 8 | 
 9 | 
10 | 11 | ```bash 12 | $ dart zones.dart 13 | 2015-10-16 15:51:25.893: received request: foo 14 | 2015-10-16 15:51:25.998: received request: bar 15 | caught: unrecognized request: bar 16 | ``` 17 | -------------------------------------------------------------------------------- /web/examples/zones/zones.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | main() { 4 | // All Dart programs implicitly run in a root zone. 5 | // runZoned creates a new zone. The new zone is a child of the root zone. 6 | runZoned(() async { 7 | await runServer(); 8 | }, 9 | // Any uncaught errors in the child zone are sent to the [onError] handler. 10 | onError: (e, stacktrace) { 11 | print('caught: $e'); 12 | }, 13 | // a ZoneSpecification allows for overriding functionality, like print() 14 | zoneSpecification: new ZoneSpecification(print: (Zone self, ZoneDelegate parent, Zone zone, String message) { 15 | parent.print(zone, '${new DateTime.now()}: $message'); 16 | }) 17 | ); 18 | } 19 | 20 | Future runServer() async { 21 | await for (var r in requests()) { 22 | print('received request: $r'); 23 | if (r == 'bar') throw('unrecognized request: $r'); 24 | } 25 | } 26 | 27 | Stream requests() async* { 28 | var dur = new Duration(milliseconds: 100); 29 | 30 | await new Future.delayed(dur); 31 | yield 'foo'; 32 | 33 | await new Future.delayed(dur); 34 | yield 'bar'; 35 | } -------------------------------------------------------------------------------- /web/hljs/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006, Ivan Sagalaev 2 | All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of highlight.js nor the names of its contributors 12 | may be used to endorse or promote products derived from this software 13 | without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY 16 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /web/hljs/highlight.pack.js: -------------------------------------------------------------------------------- 1 | !function(e){"undefined"!=typeof exports?e(exports):(window.hljs=e({}),"function"==typeof define&&define.amd&&define("hljs",[],function(){return window.hljs}))}(function(e){function n(e){return e.replace(/&/gm,"&").replace(//gm,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0==t.index}function a(e){return/^(no-?highlight|plain|text)$/i.test(e)}function i(e){var n,t,r,i=e.className+" ";if(i+=e.parentNode?e.parentNode.className:"",t=/\blang(?:uage)?-([\w-]+)\b/i.exec(i))return w(t[1])?t[1]:"no-highlight";for(i=i.split(/\s+/),n=0,r=i.length;r>n;n++)if(w(i[n])||a(i[n]))return i[n]}function o(e,n){var t,r={};for(t in e)r[t]=e[t];if(n)for(t in n)r[t]=n[t];return r}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3==i.nodeType?a+=i.nodeValue.length:1==i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!=r[0].offset?e[0].offset"}function u(e){f+=""}function c(e){("start"==e.event?o:u)(e.node)}for(var s=0,f="",l=[];e.length||r.length;){var g=i();if(f+=n(a.substr(s,g[0].offset-s)),s=g[0].offset,g==e){l.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g==e&&g.length&&g[0].offset==s);l.reverse().forEach(o)}else"start"==g[0].event?l.push(g[0].node):l.pop(),c(g.splice(0,1)[0])}return f+n(a.substr(s))}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var u={},c=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");u[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?c("keyword",a.k):Object.keys(a.k).forEach(function(e){c(e,a.k[e])}),a.k=u}a.lR=t(a.l||/\b\w+\b/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),void 0===a.r&&(a.r=1),a.c||(a.c=[]);var s=[];a.c.forEach(function(e){e.v?e.v.forEach(function(n){s.push(o(e,n))}):s.push("self"==e?a:e)}),a.c=s,a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var f=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=f.length?t(f.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){for(var t=0;t";return i+=e+'">',i+n+o}function p(){if(!L.k)return n(y);var e="",t=0;L.lR.lastIndex=0;for(var r=L.lR.exec(y);r;){e+=n(y.substr(t,r.index-t));var a=g(L,r);a?(B+=a[1],e+=h(a[0],n(r[0]))):e+=n(r[0]),t=L.lR.lastIndex,r=L.lR.exec(y)}return e+n(y.substr(t))}function d(){var e="string"==typeof L.sL;if(e&&!x[L.sL])return n(y);var t=e?f(L.sL,y,!0,M[L.sL]):l(y,L.sL.length?L.sL:void 0);return L.r>0&&(B+=t.r),e&&(M[L.sL]=t.top),h(t.language,t.value,!1,!0)}function b(){return void 0!==L.sL?d():p()}function v(e,t){var r=e.cN?h(e.cN,"",!0):"";e.rB?(k+=r,y=""):e.eB?(k+=n(t)+r,y=""):(k+=r,y=t),L=Object.create(e,{parent:{value:L}})}function m(e,t){if(y+=e,void 0===t)return k+=b(),0;var r=o(t,L);if(r)return k+=b(),v(r,t),r.rB?0:t.length;var a=u(L,t);if(a){var i=L;i.rE||i.eE||(y+=t),k+=b();do L.cN&&(k+=""),B+=L.r,L=L.parent;while(L!=a.parent);return i.eE&&(k+=n(t)),y="",a.starts&&v(a.starts,""),i.rE?0:t.length}if(c(t,L))throw new Error('Illegal lexeme "'+t+'" for mode "'+(L.cN||"")+'"');return y+=t,t.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,L=i||N,M={},k="";for(R=L;R!=N;R=R.parent)R.cN&&(k=h(R.cN,"",!0)+k);var y="",B=0;try{for(var C,j,I=0;;){if(L.t.lastIndex=I,C=L.t.exec(t),!C)break;j=m(t.substr(I,C.index-I),C[0]),I=C.index+j}for(m(t.substr(I)),R=L;R.parent;R=R.parent)R.cN&&(k+="");return{r:B,value:k,language:e,top:L}}catch(O){if(-1!=O.message.indexOf("Illegal"))return{r:0,value:n(t)};throw O}}function l(e,t){t=t||E.languages||Object.keys(x);var r={r:0,value:n(e)},a=r;return t.forEach(function(n){if(w(n)){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}}),a.language&&(r.second_best=a),r}function g(e){return E.tabReplace&&(e=e.replace(/^((<[^>]+>|\t)+)/gm,function(e,n){return n.replace(/\t/g,E.tabReplace)})),E.useBR&&(e=e.replace(/\n/g,"
")),e}function h(e,n,t){var r=n?R[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function p(e){var n=i(e);if(!a(n)){var t;E.useBR?(t=document.createElementNS("http://www.w3.org/1999/xhtml","div"),t.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):t=e;var r=t.textContent,o=n?f(n,r,!0):l(r),s=u(t);if(s.length){var p=document.createElementNS("http://www.w3.org/1999/xhtml","div");p.innerHTML=o.value,o.value=c(s,u(p),r)}o.value=g(o.value),e.innerHTML=o.value,e.className=h(e.className,n,o.language),e.result={language:o.language,re:o.r},o.second_best&&(e.second_best={language:o.second_best.language,re:o.second_best.r})}}function d(e){E=o(E,e)}function b(){if(!b.called){b.called=!0;var e=document.querySelectorAll("pre code");Array.prototype.forEach.call(e,p)}}function v(){addEventListener("DOMContentLoaded",b,!1),addEventListener("load",b,!1)}function m(n,t){var r=x[n]=t(e);r.aliases&&r.aliases.forEach(function(e){R[e]=n})}function N(){return Object.keys(x)}function w(e){return e=e.toLowerCase(),x[e]||x[R[e]]}var E={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},x={},R={};return e.highlight=f,e.highlightAuto=l,e.fixMarkup=g,e.highlightBlock=p,e.configure=d,e.initHighlighting=b,e.initHighlightingOnLoad=v,e.registerLanguage=m,e.listLanguages=N,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e});hljs.registerLanguage("dart",function(e){var t={cN:"subst",b:"\\$\\{",e:"}",k:"true false null this is new super"},r={cN:"string",v:[{b:"r'''",e:"'''"},{b:'r"""',e:'"""'},{b:"r'",e:"'",i:"\\n"},{b:'r"',e:'"',i:"\\n"},{b:"'''",e:"'''",c:[e.BE,t]},{b:'"""',e:'"""',c:[e.BE,t]},{b:"'",e:"'",i:"\\n",c:[e.BE,t]},{b:'"',e:'"',i:"\\n",c:[e.BE,t]}]};t.c=[e.CNM,r];var n={keyword:"assert break case catch class const continue default do else enum extends false final finally for if in is new null rethrow return super switch this throw true try var void while with",literal:"abstract as dynamic export external factory get implements import library operator part set static typedef",built_in:"print Comparable DateTime Duration Function Iterable Iterator List Map Match Null Object Pattern RegExp Set Stopwatch String StringBuffer StringSink Symbol Type Uri bool double int num document window querySelector querySelectorAll Element ElementList"};return{k:n,c:[r,e.C("/\\*\\*","\\*/",{sL:"markdown"}),e.C("///","$",{sL:"markdown"}),e.CLCM,e.CBCM,{cN:"class",bK:"class interface",e:"{",eE:!0,c:[{bK:"extends implements"},e.UTM]},e.CNM,{cN:"annotation",b:"@[A-Za-z]+"},{b:"=>"}]}});hljs.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},s={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/-?[a-z\.]+/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",operator:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"shebang",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,e.NM,s,a,t]}}); -------------------------------------------------------------------------------- /web/hljs/styles/mono-blue.css: -------------------------------------------------------------------------------- 1 | /* 2 | Five-color theme from a single blue hue. 3 | */ 4 | .hljs { 5 | display: block; 6 | overflow-x: auto; 7 | padding: 0.5em; 8 | background: #eaeef3; 9 | -webkit-text-size-adjust: none; 10 | } 11 | 12 | .hljs, 13 | .hljs-list .hljs-built_in { 14 | color: #00193a; 15 | } 16 | 17 | .hljs-keyword, 18 | .hljs-title, 19 | .hljs-important, 20 | .hljs-request, 21 | .hljs-header, 22 | .hljs-doctag { 23 | font-weight: bold; 24 | } 25 | 26 | .hljs-comment, 27 | .hljs-chunk { 28 | color: #738191; 29 | } 30 | 31 | .hljs-string, 32 | .hljs-title, 33 | .hljs-parent, 34 | .hljs-built_in, 35 | .hljs-literal, 36 | .hljs-filename, 37 | .hljs-value, 38 | .hljs-addition, 39 | .hljs-tag, 40 | .hljs-argument, 41 | .hljs-link_label, 42 | .hljs-blockquote, 43 | .hljs-header, 44 | .hljs-name { 45 | color: #0048ab; 46 | } 47 | 48 | .hljs-decorator, 49 | .hljs-prompt, 50 | .hljs-subst, 51 | .hljs-symbol, 52 | .hljs-doctype, 53 | .hljs-regexp, 54 | .hljs-preprocessor, 55 | .hljs-pragma, 56 | .hljs-pi, 57 | .hljs-attribute, 58 | .hljs-attr_selector, 59 | .hljs-xmlDocTag, 60 | .hljs-deletion, 61 | .hljs-shebang, 62 | .hljs-string .hljs-variable, 63 | .hljs-link_url, 64 | .hljs-bullet, 65 | .hljs-sqbracket, 66 | .hljs-phony { 67 | color: #4c81c9; 68 | } 69 | -------------------------------------------------------------------------------- /web/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Dart By Example" 3 | template: web/templates/_index.mustache 4 | --- 5 | 6 | {{> web/templates/_header.md}} 7 | 8 | {{> web/templates/_intro.md}} 9 | 10 | {{> web/templates/_examples.md}} 11 | 12 | {{> web/templates/_footer.md}} 13 | -------------------------------------------------------------------------------- /web/site.scss: -------------------------------------------------------------------------------- 1 | @import 'reset'; 2 | 3 | $content-width: 420px; 4 | $example-width: 640; 5 | $code-bg-color: #e5e9f0; 6 | $font-size: 16px; 7 | $code-size: 13px; 8 | $header-size: 32px; 9 | $link-color: #000; 10 | $text-color: #252519; 11 | 12 | body { 13 | font-family: 'Georgia', serif; 14 | font-size: $font-size; 15 | line-height: 20px; 16 | color: $text-color; 17 | } 18 | 19 | em { 20 | font-style: italic; 21 | } 22 | 23 | a, a:visited { 24 | color: $link-color; 25 | } 26 | 27 | h2 { 28 | font-size: $header-size; 29 | line-height: 40px; 30 | margin-top: 40px; 31 | padding-bottom: 20px; 32 | } 33 | 34 | h2 a, h2 a:visited { 35 | text-decoration: none; 36 | color: $text-color; 37 | } 38 | 39 | div.example { 40 | width: $example-width; 41 | min-width: $example-width; 42 | max-width: $example-width; 43 | margin-left: auto; 44 | margin-right: auto; 45 | margin-bottom: 120px; 46 | } 47 | 48 | .footer { 49 | padding-top: 10px; 50 | } 51 | .footer, .footer a, .footer a:visited { 52 | color: grey; 53 | } 54 | 55 | div#intro { 56 | width: $content-width; 57 | min-width: $content-width; 58 | max-width: $content-width; 59 | margin-left: auto; 60 | margin-right: auto; 61 | margin-bottom: 120px; 62 | } 63 | 64 | p { 65 | padding-bottom: 15px; 66 | } 67 | 68 | div#intro p { 69 | padding-top: 20px; 70 | } 71 | 72 | div#intro ul { 73 | padding-top: 20px; 74 | } 75 | 76 | pre, code { 77 | font-size: $code-size; 78 | line-height: 18px; 79 | font-family: 'Menlo', 'Monaco', 'Consolas', 'Lucida Console', monospace; 80 | white-space: pre; 81 | } 82 | 83 | pre { 84 | margin-top: 10px; 85 | margin-bottom: 10px; 86 | } 87 | 88 | code { 89 | background-color: $code-bg-color; 90 | } 91 | 92 | img.run { 93 | height: 16px; 94 | width: 16px; 95 | float: right 96 | } 97 | -------------------------------------------------------------------------------- /web/templates/_example.mustache: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dart by example: {{title}} 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |

Dart by Example: {{title}}

12 | {{{content}}} 13 | 14 | 19 |
20 | 21 | -------------------------------------------------------------------------------- /web/templates/_example_header.htmlcontent: -------------------------------------------------------------------------------- 1 |

Dart By Example: {{title}}

2 | -------------------------------------------------------------------------------- /web/templates/_examples.md: -------------------------------------------------------------------------------- 1 | - [Hello World](examples/hello_world/) 2 | - [Values](examples/values/) 3 | - [Variables](examples/variables/) 4 | - [For](examples/for/) 5 | - [If / Else](examples/ifelse/) 6 | - [Null-Aware Operators](examples/null_aware/) 7 | - [While](examples/while/) 8 | - [Switch](examples/switch/) 9 | - [Exceptions](examples/exceptions/) 10 | - [List](examples/list/) 11 | - [Map](examples/map/) 12 | - [Set](examples/set/) 13 | - [Queue](examples/queue/) 14 | - [Functions](examples/functions/) 15 | - [Optional Parameters](examples/optional_params/) 16 | - [Lexical Scope](examples/lexical_scope/) 17 | - [Function Types](examples/typedef/) 18 | - [Unused Variables](examples/unused_variables/) 19 | - [Constants](examples/const/) 20 | - [Final](examples/final/) 21 | - [Static](examples/static/) 22 | - [Classes](examples/classes/) 23 | - [Constructors](examples/constructors/) 24 | - [Initializer Lists](examples/initializer_lists/) 25 | - [Getters and Setters](examples/getters_setters/) 26 | - [Inheritance](examples/inheritance/) 27 | - [Mixins](examples/mixins/) 28 | - [Libraries](examples/libraries/) 29 | - [Pub](examples/pub/) 30 | - [Comments](examples/comments/) 31 | - [Futures](examples/futures/) 32 | - [Streams](examples/streams/) 33 | - [Iterators](examples/iterators/) 34 | - [Iterables](examples/iterables/) 35 | - [Async / Await](examples/async_await/) 36 | - [Sync* (Generators)](examples/generators/) 37 | - [Async*](examples/async_star/) 38 | - [Await For](examples/await_for/) 39 | - [Yield*](examples/yield_star/) 40 | - [Zones](examples/zones/) 41 | - [Microtasks](examples/microtasks/) 42 | - [Isolates](examples/isolates/) 43 | - [Http Server](examples/http_server/) 44 | - [Http Requests](examples/http_request/) 45 | -------------------------------------------------------------------------------- /web/templates/_footer.md: -------------------------------------------------------------------------------- 1 |