Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize cmdline example migrations and updates #3276

Merged
merged 2 commits into from Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -4,9 +4,9 @@ void printEnvVar() {
// #docregion env
final envVarMap = Platform.environment;

print('PWD = ${envVarMap["PWD"]}');
print('LOGNAME = ${envVarMap["LOGNAME"]}');
print('PATH = ${envVarMap["PATH"]}');
print('PWD = ${envVarMap['PWD']}');
print('LOGNAME = ${envVarMap['LOGNAME']}');
print('PATH = ${envVarMap['PATH']}');
// #enddocregion env
}

Expand All @@ -25,7 +25,7 @@ Future<void> writeQuotes() async {
final quotes = File('quotes.txt').openWrite(mode: FileMode.append);

quotes.write("Don't cry because it's over, ");
quotes.writeln("smile because it happened. -Dr. Seuss");
quotes.writeln('smile because it happened. -Dr. Seuss');
await quotes.close();
// #enddocregion write-quotes
print('Done!');
Expand Down
16 changes: 8 additions & 8 deletions src/_tutorials/server/cmdline.md
Expand Up @@ -63,7 +63,7 @@ Let's run a small program.

1. Create a file called `hello_world.dart` that contains this code:

<?code-excerpt "misc/test/samples_test.dart (hello-world)"?>
<?code-excerpt "../null_safety_examples/misc/test/samples_test.dart (hello-world)"?>
```dart
void main() {
print('Hello, World!');
Expand Down Expand Up @@ -426,7 +426,7 @@ The easiest way to write text to a file is to create a
[File]({{ioAPI}}/File-class.html)
object and use the `writeAsString()` method:

<?code-excerpt "misc/lib/tutorial/cmdline.dart (write quote)"?>
<?code-excerpt "../null_safety_examples/misc/lib/tutorial/cmdline.dart (write quote)"?>
```dart
final quotes = File('quotes.txt');
const stronger = 'That which does not kill us makes us stronger. -Nietzsche';
Expand All @@ -447,12 +447,12 @@ You can continue to write to the file until done,
at which time, you must close the file.
The `close()` method is asynchronous and returns a future.

<?code-excerpt "misc/lib/tutorial/cmdline.dart (write quotes)"?>
<?code-excerpt "../null_safety_examples/misc/lib/tutorial/cmdline.dart (write quotes)"?>
```dart
final quotes = File('quotes.txt').openWrite(mode: FileMode.append);

quotes.write("Don't cry because it's over, ");
quotes.writeln("smile because it happened. -Dr. Seuss");
quotes.writeln('smile because it happened. -Dr. Seuss');
await quotes.close();
```

Expand All @@ -468,13 +468,13 @@ provides a copy of the environment
variables in an immutable map. If you need a mutable map (modifiable copy) you
can use `Map.of(Platform.environment)`.

<?code-excerpt "misc/lib/tutorial/cmdline.dart (env)"?>
<?code-excerpt "../null_safety_examples/misc/lib/tutorial/cmdline.dart (env)"?>
```dart
final envVarMap = Platform.environment;

print('PWD = ${envVarMap["PWD"]}');
print('LOGNAME = ${envVarMap["LOGNAME"]}');
print('PATH = ${envVarMap["PATH"]}');
print('PWD = ${envVarMap['PWD']}');
print('LOGNAME = ${envVarMap['LOGNAME']}');
print('PATH = ${envVarMap['PATH']}');
```

`Platform` provides other useful properties that give
Expand Down
2 changes: 1 addition & 1 deletion src/_tutorials/server/get-started.md
Expand Up @@ -30,7 +30,7 @@ greeting to use another language.
{% include dartpad-embedded-troubleshooting.md %}
{{site.alert.end}}

<?code-excerpt "misc/test/samples_test.dart (hello-world)"?>
<?code-excerpt "../null_safety_examples/misc/test/samples_test.dart (hello-world)"?>
```dart:run-dartpad:ga_id-hello_world
void main() {
print('Hello, World!');
Expand Down
2 changes: 1 addition & 1 deletion src/assets/dash/js/dartpad_picker_main.dart.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tool/dartpad_picker/web/dartpad_picker_main.dart
Expand Up @@ -46,7 +46,7 @@ bool isMobile() {

const helloWorld = r'''
void main() {
print("Hello, World!");
print('Hello, World!');
}''';

const functions = r'''
Expand Down