-
Notifications
You must be signed in to change notification settings - Fork 724
Adds chapter 3, Async and HTTP, to the Dart first week experience #6629
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
base: main
Are you sure you want to change the base?
Conversation
Visit the preview URL for this PR (updated for commit ae2c82a): https://dart-dev--pr6629-feature-guide-fwe-chapter-3-o2ec7h6a.web.app |
0f76fe3
to
ae2c82a
Compare
@ericwindmill At the end of this chapter, after doing the final test, the program doesn't terminate. Do you think it's too complicated to close the HTTP client, or should we add that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! After you've finished with the technical review, let me know and I'll do a last minute editorial sweep over all of the things.
@@ -1,6 +1,14 @@ | |||
--- | |||
title: Making your CLI program interactive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make
(move to active voice in headings https://developers.google.com/style/headings)
|
||
In this chapter, you'll explore asynchronous programming in Dart, allowing your | ||
applications to perform multiple tasks concurrently. You'll learn how to fetch | ||
data from the internet using the `http` package, specifically retrieving an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data from the internet using the `http` package, specifically retrieving an | |
data from the internet using the `http` package to retrieve an |
(I'd do a search for -ing present participles and gerunds and reduce the amount of them, if possible. )
description: Add simple commands to your cli program. Learn the fundamentals of Dart syntax including control flow, collections, variables, functions, and more. | ||
short-title: Add commands | ||
description: >- | ||
Add simple commands to your cli program. Learn the fundamentals of Dart syntax including control flow, collections, variables, functions, and more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLI application?
Before you can make HTTP requests, you need to add the `http` package | ||
as a dependency to your project. | ||
|
||
1. Open the `dartpedia/pubspec.yaml` file within your project. This file is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a small thing, but can you change your numbers to use this format so that you don't have to worry about incrementation issues in the future:
1. stuff
1. more stuff
1. even more stuff
``` | ||
|
||
This line imports the `http` package and gives it the alias `http`. | ||
This allows you to refer to classes and functions within the `http` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows you to refer to classes and functions within the `http` | |
After you do this, you can refer to classes and functions within the `http` |
|
||
### Task 5: Update `main` to call `runApp` | ||
|
||
Finally, you need to update your `main` function to call the new `runApp` function when the `wikipedia` command is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, you need to update your `main` function to call the new `runApp` function when the `wikipedia` command is used. | |
Finally, update your `main` function to call the new `runApp` function when the `wikipedia` command is used. |
} | ||
} | ||
``` | ||
* `arguments.sublist(1)`: This extracts all elements from the `arguments` list starting from the second element (index 1). This effectively removes the `wikipedia` command itself, so `runApp` only receives the actual article title arguments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update formatting to match other sections.
} | ||
``` | ||
* `arguments.sublist(1)`: This extracts all elements from the `arguments` list starting from the second element (index 1). This effectively removes the `wikipedia` command itself, so `runApp` only receives the actual article title arguments. | ||
* `runApp(inputArgs)`: We call `runApp` directly. Since `main` doesn't need to do anything after `runApp` completes, we don't need to `await` it from `main` (and therefore `main` doesn't need to be `async`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using 'we'. I'd do a search and replace.
|
||
### Task 6: Running the application | ||
|
||
Now that you've implemented the `http` request and integrated it into your application, let's test it out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you've implemented the `http` request and integrated it into your application, let's test it out. | |
Now that you've implemented the `http` request and integrated it into your application, test it out. |
|
||
1. Open your terminal and navigate to the `dartpedia` directory. | ||
2. Run the command `dart run bin/cli.dart wikipedia Dart`. | ||
3. The application should now fetch the summary of the "Dart" article from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3. The application should now fetch the summary of the "Dart" article from | |
3. Check to make sure that the application fetched the summary of the "Dart" article from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to start each step with the thing you want to do.
updates to ch3
Thanks for your contribution! Please replace this text with a description of what this PR is changing or adding and why, list any relevant issues, and review the contribution guidelines below.
Fixes
Contribution guidelines:
dart format
.<?code-excerpt
need to be updated in their source.dart
file as well.