-
Notifications
You must be signed in to change notification settings - Fork 3.3k
FWE pt 1 #12035
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
ericwindmill
wants to merge
15
commits into
main
Choose a base branch
from
flutter-tutorial
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
FWE pt 1 #12035
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cc88be2
start adding part one content
ericwindmill a7c6eb6
add next lesson markdown
ericwindmill 877f053
fix codeblock
ericwindmill 49c09ae
format
ericwindmill 9537045
Merge branch 'main' of https://github.com/flutter/website into flutte…
ericwindmill bb49d0d
adds layout lesson
ericwindmill 0e6747e
adds devtools lesson
ericwindmill 43f94e0
Merge branch 'main' of https://github.com/flutter/website into flutte…
ericwindmill 714972a
fixes docs links
ericwindmill f1114eb
fixes docs links
ericwindmill 16c8df1
add user input
ericwindmill 2d47d4f
cleanup
ericwindmill 5b0895d
cleanup
ericwindmill e7f4d03
add stateful widget lesson
ericwindmill 346fd6d
add implicit animations
ericwindmill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: Learn Flutter | ||
description: Resources to help you learn Flutter. | ||
toc: false | ||
--- | ||
|
||
## Welcome! | ||
|
||
Welcome to the Flutter tutorial! This tutorial teaches you how to build | ||
applications from scratch that run on mobile, desktop, and web. | ||
|
||
You’ll start from the very beginning: creating a blank Flutter application. | ||
By the end, you’ll have built a handful of small apps that demonstrate | ||
the critical features of Flutter development (and more!) | ||
|
||
{%- comment %} | ||
TODO(ewindmill) welcome video | ||
{%- endcomment %} | ||
|
||
## What is Flutter? | ||
|
||
Flutter is an open-source UI toolkit that helps you build native compiled, | ||
expressive apps across mobile, web, and desktop from a single codebase. | ||
It’s declarative, reactive, features hot reload for fast development cycles, | ||
and has a rich set of customizable widgets for creating expressive interfaces. | ||
|
||
Flutter draws every pixel itself rather than wrapping native components, | ||
giving developers complete control over the UI and ensuring visual consistency | ||
across platforms. | ||
|
||
## How to use this tutorial | ||
|
||
You should be familiar with the Dart programming language to follow this | ||
tutorial. This tutorial assumes you have all the knowledge from its Dart | ||
counterpart, the [Learn Dart tutorial][]. (Alternatively, if you’re comfortable | ||
with another all-purpose object oriented language, like Java or Kotlin, you’ll | ||
likely be okay.) | ||
|
||
## Set up | ||
|
||
While reading this tutorial, you’ll ideally be coding along with the examples presented. | ||
You can do so by [installing Flutter on your machine][], | ||
or by using [Firebase Studio][], a web IDE that supports Flutter. | ||
|
||
If you’re running locally, this tutorial assumes that you’re running Flutter | ||
apps on the web, using [Chrome][]. This doesn’t require Xcode or Android Studio, | ||
and thus is the quickest way to start using Flutter. | ||
If you prefer to run Flutter apps on Android, | ||
iOS, MacOS, or any other supported platform, you’ll have no problem following the tutorial. | ||
But some features, like resizing a window to see how UI renders | ||
on different screen sizes, aren’t available on mobile simulators. | ||
|
||
[Learn Dart tutorial]: https://dart.dev/ | ||
[installing Flutter on your machine]: /get-started/install | ||
[Firebase Studio]: https://firebase.studio/ | ||
[Chrome]: https://www.google.com/chrome/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,131 @@ | ||||||
--- | ||||||
title: Create an app | ||||||
description: Instructions on how to create a new Flutter app. | ||||||
permalink: /tutorial/create-an-app/ | ||||||
--- | ||||||
|
||||||
{%- comment %} | ||||||
<!-- TODO(ewindmill) embed video --> | ||||||
{%- endcomment %} | ||||||
|
||||||
In this first section of the Flutter tutorial, you’ll build the core UI of an | ||||||
app called ‘Birdle’, a game similar to [Wordle, the popular New York Times | ||||||
game][]. | ||||||
|
||||||
By the end of this tutorial, you’ll have learned the fundamentals of building | ||||||
Flutter UIs, and your app will look like the following screenshot (and it’ll | ||||||
even mostly work 😀). | ||||||
|
||||||
{%- comment %} | ||||||
<!-- TODO(ewindmill) screenshot --> | ||||||
{%- endcomment %} | ||||||
|
||||||
## Create a new Flutter project | ||||||
|
||||||
The first step to building Flutter apps is to create a new project. You create | ||||||
new apps with the [Flutter CLI tool][], installed as part of the Flutter SDK. | ||||||
|
||||||
Open your terminal or command prompt and run the following command to create a | ||||||
new Flutter project: | ||||||
|
||||||
```shell | ||||||
$ flutter create birdle --empty | ||||||
``` | ||||||
|
||||||
This creates a new Flutter project using the minimal “empty” template. | ||||||
|
||||||
## Examine the code | ||||||
|
||||||
In your IDE, open the file at `lib/main.dart`. Starting from the top, you’ll see | ||||||
this code. | ||||||
|
||||||
```dart | ||||||
import 'package:flutter/material.dart'; // imports Flutter | ||||||
|
||||||
void main() { | ||||||
runApp(const MainApp()); | ||||||
} | ||||||
// ... | ||||||
``` | ||||||
|
||||||
The `main` function is the entry point to any Dart program, and a Flutter app is | ||||||
just a **Dart** program. The `runApp` method is part of the Flutter SDK, and it | ||||||
takes a **widget** as an argument. (Most of this tutorial is about widgets, but | ||||||
in the simplest terms a widget is a Dart object that describes a piece of UI.) | ||||||
In this case, an instance of the `MainApp` widget is being passed in. | ||||||
|
||||||
Just below the `main` function, you’ll find the `MainApp` class declaration. | ||||||
|
||||||
```dart | ||||||
class MainApp extends StatelessWidget { | ||||||
const MainApp({super.key}); | ||||||
|
||||||
@override | ||||||
Widget build(BuildContext context) { | ||||||
return const MaterialApp( | ||||||
home: Scaffold( | ||||||
body: Center( | ||||||
child: Text('Hello World!'), | ||||||
), | ||||||
), | ||||||
); | ||||||
} | ||||||
} | ||||||
|
||||||
``` | ||||||
|
||||||
`MainApp` is the **root widget**, as it’s the widget that’s passed into | ||||||
`runApp`. Within this widget, there’s a `build` method, which returns another | ||||||
widget called `MaterialApp`. Essentially, this is what a Flutter app is: a | ||||||
composition of Widgets that make up a tree structure called the **widget tree.** | ||||||
Your job as a Flutter developer is to compose widgets from the SDK into larger, | ||||||
custom widgets that display a UI. | ||||||
|
||||||
At the moment, the widget tree is quite simple: | ||||||
|
||||||
{%- comment %} | ||||||
<!-- TODO(ewindmill) widget tree diagram --> | ||||||
{%- endcomment %} | ||||||
|
||||||
## Run your app | ||||||
|
||||||
In your terminal at the root of your Flutter app, run: | ||||||
|
||||||
```shell | ||||||
$ flutter run -d chrome | ||||||
``` | ||||||
|
||||||
The app will build and launch in a new instance of chrome. | ||||||
|
||||||
{%- comment %} | ||||||
<!-- TODO(ewindmill) screenshot of app at start --> | ||||||
{%- endcomment %} | ||||||
|
||||||
|
||||||
## Hot reload | ||||||
|
||||||
**Stateful hot reload**, if you haven't heard of it, allows a running Flutter | ||||||
app to re-render updated business logic or UI code in less than a second - all | ||||||
without losing your place in the app. This is the part that hooks most Flutter | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
developers. | ||||||
|
||||||
In your IDE, open the `main.dart` file and navigate to line \~15 and find this | ||||||
code: | ||||||
|
||||||
```dart | ||||||
child: Text('Hello World!'), | ||||||
``` | ||||||
|
||||||
Change the text inside the string to anything you want. Then, hot-reload your | ||||||
app by pressing `r` in your terminal where the app is running. The running app | ||||||
should instantly show your updated text. | ||||||
|
||||||
This is only part of the power of hot reload, because the app doesn’t currently | ||||||
have ephemeral state. If the app did have state that could change, you’d see | ||||||
that you can update the code and the app will maintain its state, making | ||||||
development cycles lightning fast. Soon, you’ll add ephemeral state and see just | ||||||
that. | ||||||
|
||||||
[Flutter CLI tool]: /reference/flutter-cli | ||||||
[Wordle, the popular New York Times game]: | ||||||
https://www.nytimes.com/games/wordle/index.html |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There's a lot of words here and it's rather confusing. At the end, you mention a limitation of simulators, but the earlier text doesn't even mention simulators. I'd tighten this up, hence the more opinionated. ;)