Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 --- | 1 --- |
| 2 layout: default | 2 layout: tutorial |
| 3 title: "Try Dart" | 3 title: "Code Lab: Ready the Pirates" |
| 4 description: "Write some Dart code. Learn some stuff." | 4 description: "Write some Dart code. Learn some stuff." |
|
sethladd
2014/01/14 22:44:06
can we convey this is a great place to starting le
mem
2014/01/15 23:22:51
Done.
| |
| 5 snippet_img: images/piratemap.jpg | 5 snippet_img: images/piratemap.jpg |
| 6 has-permalinks: true | 6 has-permalinks: true |
| 7 tutorial: | 7 tutorial: |
| 8 id: trydart | 8 id: trydart |
| 9 js: | 9 js: |
| 10 - url: /js/os-switcher.js | 10 - url: /js/os-switcher.js |
| 11 defer: true | 11 defer: true |
| 12 - url: /js/editor-downloads-analytics.js | 12 - url: /js/editor-downloads-analytics.js |
| 13 defer: true | 13 defer: true |
| 14 - url: /js/editor-version.js | 14 - url: /js/editor-version.js |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 In this step, you download Dart and get the sample code. | 56 In this step, you download Dart and get the sample code. |
| 57 | 57 |
| 58 | 58 |
| 59 ### <i class="fa fa-anchor"> </i> Get Dart. | 59 ### <i class="fa fa-anchor"> </i> Get Dart. |
| 60 | 60 |
| 61 <div class="trydart-step-details" markdown="1"> | 61 <div class="trydart-step-details" markdown="1"> |
| 62 If you haven't already done so, | 62 If you haven't already done so, |
| 63 get the Dart download. | 63 get the Dart download. |
| 64 Unzip the ZIP file, which creates a directory called `dart`. | 64 Unzip the ZIP file, which creates a directory called `dart`. |
| 65 | 65 |
| 66 <!--style here is a hack to remove the arrow, which was only partially showing. --> | |
| 67 <div style="padding-left: 10px"> | |
|
sethladd
2014/01/14 22:44:06
does this happen only in the code lab?
mem
2014/01/15 23:22:51
It's about centering...
If the button is centered
| |
| 66 {% include downloads/_dart-editor.html buttonclass="btn btn-primary btn-lg" %} | 68 {% include downloads/_dart-editor.html buttonclass="btn btn-primary btn-lg" %} |
| 69 </div> | |
| 67 | 70 |
| 68 <p class="os-choices" markdown="1"> | 71 <p class="os-choices" markdown="1"> |
| 69 The Dart tools | 72 The Dart tools |
| 70 work in recent versions of | 73 work in recent versions of |
| 71 {% include os-choices.html %} | 74 {% include os-choices.html %} |
| 72 </p> | 75 </p> |
| 73 </div> | 76 </div> |
| 74 | 77 |
| 75 ### <i class="fa fa-anchor"> </i> Start the editor. | 78 ### <i class="fa fa-anchor"> </i> Start the editor. |
| 76 | 79 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 98 use **File > Open Existing Folder...** | 101 use **File > Open Existing Folder...** |
| 99 to open the `one-hour-codelab-master` directory. | 102 to open the `one-hour-codelab-master` directory. |
| 100 </div> | 103 </div> |
| 101 | 104 |
| 102 <div class="row"> <div class="col-md-7" markdown="1"> | 105 <div class="row"> <div class="col-md-7" markdown="1"> |
| 103 | 106 |
| 104  | 107  |
| 105 | 108 |
| 106 </div> <div class="col-md-5" markdown="1"> | 109 </div> <div class="col-md-5" markdown="1"> |
| 107 | 110 |
| 108 <i class="fa fa-key"> </i> <strong> Key Information </strong> | 111 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 109 | 112 |
| 110 * The `packages` directory, as well as the `pubspec.yaml` and `pubspec.lock` fil es are | 113 * The `packages` directory, as well as the `pubspec.yaml` and `pubspec.lock` fil es are |
| 111 related to package dependencies. | 114 related to package dependencies. |
| 112 This project has all the dependencies set up for you. | 115 This project has all the dependencies set up for you. |
| 113 Dart Editor automatically installs the necessary packages. | 116 Dart Editor automatically installs the necessary packages. |
| 114 | 117 |
| 115 * Several numbered directories contain the completed code for each step. | 118 * Several numbered directories contain the completed code for each step. |
| 116 `1-blankbadge` contains the skeletal version of the app that you begin with. | 119 `1-blankbadge` contains the skeletal version of the app that you begin with. |
| 117 `6-piratebadge_json` contains the final version of the app. | 120 `6-piratebadge_json` contains the final version of the app. |
| 118 | 121 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 [[highlight]]<script src="packages/browser/dart.js"></script>[[/highlight]] | 190 [[highlight]]<script src="packages/browser/dart.js"></script>[[/highlight]] |
| 188 </body> | 191 </body> |
| 189 </html> | 192 </html> |
| 190 {% endprettify %} | 193 {% endprettify %} |
| 191 | 194 |
| 192 </div> | 195 </div> |
| 193 <div class="trydart-filename">piratebadge.html</div> | 196 <div class="trydart-filename">piratebadge.html</div> |
| 194 | 197 |
| 195 </div> <div class="col-md-5" markdown="1"> | 198 </div> <div class="col-md-5" markdown="1"> |
| 196 | 199 |
| 197 <i class="fa fa-key"> </i> <strong> Key Information </strong> | 200 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 198 | 201 |
| 199 * During this code lab, | 202 * During this code lab, |
| 200 all the changes you make to `piratebadge.html` are within | 203 all the changes you make to `piratebadge.html` are within |
| 201 the <div> element identified with the class `widgets`. | 204 the <div> element identified with the class `widgets`. |
| 202 | 205 |
| 203 * In later steps, | 206 * In later steps, |
| 204 the <span> element with the ID `badgeName` | 207 the <span> element with the ID `badgeName` |
| 205 is programmatically updated by the Dart code | 208 is programmatically updated by the Dart code |
| 206 based on user input. | 209 based on user input. |
| 207 | 210 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 </div>[[/highlight]] | 299 </div>[[/highlight]] |
| 297 </div> | 300 </div> |
| 298 ... | 301 ... |
| 299 {% endprettify %} | 302 {% endprettify %} |
| 300 </div> | 303 </div> |
| 301 | 304 |
| 302 <div class="trydart-filename">piratebadge.html</div> | 305 <div class="trydart-filename">piratebadge.html</div> |
| 303 | 306 |
| 304 </div> <div class="col-md-5" markdown="1"> | 307 </div> <div class="col-md-5" markdown="1"> |
| 305 | 308 |
| 306 <i class="fa fa-key"> </i> <strong> Key Information </strong> | 309 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 307 | 310 |
| 308 * The ID for the input element is `inputName`. | 311 * The ID for the input element is `inputName`. |
| 309 Dart uses CSS selectors, like this ID, | 312 Dart uses CSS selectors, like this ID, |
| 310 to get elements from the DOM. | 313 to get elements from the DOM. |
| 311 | 314 |
| 312 {% comment %} non-breaking space required for bootstrap/markdown bogosity {% endcomment %} | 315 {% comment %} non-breaking space required for bootstrap/markdown bogosity {% endcomment %} |
| 313 | 316 |
| 314 </div> </div> | 317 </div> </div> |
| 315 | 318 |
| 316 ### <i class="fa fa-anchor"> </i> Edit piratebadge.dart. | 319 ### <i class="fa fa-anchor"> </i> Edit piratebadge.dart. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 </div>[[/highlight]] | 482 </div>[[/highlight]] |
| 480 </div> | 483 </div> |
| 481 ... | 484 ... |
| 482 {% endprettify %} | 485 {% endprettify %} |
| 483 </div> | 486 </div> |
| 484 | 487 |
| 485 <div class="trydart-filename">piratebadge.html</div> | 488 <div class="trydart-filename">piratebadge.html</div> |
| 486 | 489 |
| 487 </div> <div class="col-md-5" markdown="1"> | 490 </div> <div class="col-md-5" markdown="1"> |
| 488 | 491 |
| 489 <i class="fa fa-key"> </i> <strong> Key Information </strong> | 492 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 490 | 493 |
| 491 * The button has the ID `generateButton` so | 494 * The button has the ID `generateButton` so |
| 492 the Dart code can get the element. | 495 the Dart code can get the element. |
| 493 | 496 |
| 494 </div> </div> | 497 </div> </div> |
| 495 | 498 |
| 496 ### <i class="fa fa-anchor"> </i> Edit piragebadge.dart. | 499 ### <i class="fa fa-anchor"> </i> Edit piragebadge.dart. |
| 497 | 500 |
| 498 <div class="trydart-step-details" markdown="1"> | 501 <div class="trydart-step-details" markdown="1"> |
| 499 Below the import, declare a top-level variable to hold the `ButtonElement`. | 502 Below the import, declare a top-level variable to hold the `ButtonElement`. |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 import 'dart:html'; | 778 import 'dart:html'; |
| 776 | 779 |
| 777 [[highlight]]import 'dart:math' show Random;[[/highlight]] | 780 [[highlight]]import 'dart:math' show Random;[[/highlight]] |
| 778 {% endprettify %} | 781 {% endprettify %} |
| 779 </div> | 782 </div> |
| 780 | 783 |
| 781 <div class="trydart-filename">piratebadge.dart</div> | 784 <div class="trydart-filename">piratebadge.dart</div> |
| 782 | 785 |
| 783 </div> <div class="col-md-5" markdown="1"> | 786 </div> <div class="col-md-5" markdown="1"> |
| 784 | 787 |
| 785 <i class="fa fa-key"> </i> <strong> Key Information </strong> | 788 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 786 | 789 |
| 787 * Using the `show` keyword, | 790 * Using the `show` keyword, |
| 788 you can import only the classes, functions, or properties you need. | 791 you can import only the classes, functions, or properties you need. |
| 789 | 792 |
| 790 * `Random` provides a random number generator. | 793 * `Random` provides a random number generator. |
| 791 | 794 |
| 792 </div></div> | 795 </div></div> |
| 793 | 796 |
| 794 <div class="trydart-step-details" markdown="1"> | 797 <div class="trydart-step-details" markdown="1"> |
| 795 | 798 |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1134 import 'dart:math' show Random; | 1137 import 'dart:math' show Random; |
| 1135 [[highlight]] | 1138 [[highlight]] |
| 1136 import 'dart:convert' show JSON;[[/highlight]] | 1139 import 'dart:convert' show JSON;[[/highlight]] |
| 1137 {% endprettify %} | 1140 {% endprettify %} |
| 1138 </div> | 1141 </div> |
| 1139 | 1142 |
| 1140 <div class="trydart-filename">piratebadge.dart</div> | 1143 <div class="trydart-filename">piratebadge.dart</div> |
| 1141 | 1144 |
| 1142 </div> <div class="col-md-5" markdown="1"> | 1145 </div> <div class="col-md-5" markdown="1"> |
| 1143 | 1146 |
| 1144 <i class="fa fa-key"> </i> <strong> Key Information </strong> | 1147 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 1145 | 1148 |
| 1146 * `JSON` provides convenient access to the most common JSON use cases. | 1149 * `JSON` provides convenient access to the most common JSON use cases. |
| 1147 | 1150 |
| 1148 </div> </div> | 1151 </div> </div> |
| 1149 | 1152 |
| 1150 <div class="trydart-step-details" markdown="1"> | 1153 <div class="trydart-step-details" markdown="1"> |
| 1151 | 1154 |
| 1152 <hr> | 1155 <hr> |
| 1153 | 1156 |
| 1154 Add a named constructor to the PirateName class. | 1157 Add a named constructor to the PirateName class. |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1417 "Queasy", "Rat", "Sandy", "Tired", | 1420 "Queasy", "Rat", "Sandy", "Tired", |
| 1418 "Ugly", "Vile", "Weak", "Xeric", | 1421 "Ugly", "Vile", "Weak", "Xeric", |
| 1419 "Yellow", "Zesty"]} | 1422 "Yellow", "Zesty"]} |
| 1420 {% endprettify %} | 1423 {% endprettify %} |
| 1421 </div> | 1424 </div> |
| 1422 | 1425 |
| 1423 <div class="trydart-filename">piratenames.json</div> | 1426 <div class="trydart-filename">piratenames.json</div> |
| 1424 | 1427 |
| 1425 </div> <div class="col-md-5" markdown="1"> | 1428 </div> <div class="col-md-5" markdown="1"> |
| 1426 | 1429 |
| 1427 <i class="fa fa-key"> </i> <strong> Key Information </strong> | 1430 <i class="fa fa-key key-header"> </i> <strong> Key Information </strong> |
| 1428 | 1431 |
| 1429 * The file contains a JSON-encoded map, | 1432 * The file contains a JSON-encoded map, |
| 1430 which contains two lists of strings. | 1433 which contains two lists of strings. |
| 1431 | 1434 |
| 1432 </div> </div> | 1435 </div> </div> |
| 1433 | 1436 |
| 1434 ### <i class="fa fa-anchor"> </i> Edit piratebadge.html. | 1437 ### <i class="fa fa-anchor"> </i> Edit piratebadge.html. |
| 1435 | 1438 |
| 1436 <div class="trydart-step-details" markdown="1"> | 1439 <div class="trydart-step-details" markdown="1"> |
| 1437 Disable the input field and the button. | 1440 Disable the input field and the button. |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1819 on our [Samples page](/samples/). | 1822 on our [Samples page](/samples/). |
| 1820 </div> | 1823 </div> |
| 1821 | 1824 |
| 1822 ### <i class="fa fa-anchor"> </i> Read the tutorials. | 1825 ### <i class="fa fa-anchor"> </i> Read the tutorials. |
| 1823 | 1826 |
| 1824 <div class="trydart-step-details" markdown="1"> | 1827 <div class="trydart-step-details" markdown="1"> |
| 1825 Learn more about Dart from | 1828 Learn more about Dart from |
| 1826 the [Dart tutorials](/docs/tutorials/). | 1829 the [Dart tutorials](/docs/tutorials/). |
| 1827 </div> | 1830 </div> |
| 1828 | 1831 |
| OLD | NEW |