Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lamek
Copy link
Contributor

@lamek lamek commented May 29, 2025

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


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
  • This PR doesn't contain automatically generated corrections or text (Grammarly, LLMs, and similar).
  • This PR follows the Google Developer Documentation Style Guidelines — for example, it doesn't use i.e. or e.g., and it avoids I and we (first person).
  • This PR uses semantic line breaks of 80 characters or fewer.
Contribution guidelines:
  • See our contributor guide for general expectations for PRs.
  • Larger or significant changes should be discussed in an issue before creating a PR.
  • Code changes should generally follow the Dart style guide and use dart format.
  • Updates to code excerpts indicated by <?code-excerpt need to be updated in their source .dart file as well.

@dart-github-bot
Copy link
Collaborator

dart-github-bot commented May 29, 2025

Visit the preview URL for this PR (updated for commit ae2c82a):

https://dart-dev--pr6629-feature-guide-fwe-chapter-3-o2ec7h6a.web.app

@lamek lamek force-pushed the feature/guide/fwe-chapter-3 branch from 0f76fe3 to ae2c82a Compare June 10, 2025 00:33
@lamek
Copy link
Contributor Author

lamek commented Jun 10, 2025

@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?

Copy link
Collaborator

@antfitch antfitch left a 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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Collaborator

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
Copy link
Collaborator

@antfitch antfitch Jun 10, 2025

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`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Collaborator

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`).
Copy link
Collaborator

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants