Chapter 3. Breaking into Flutter

 

This chapter covers

  • Dissecting Flutter basics via the Increment app
  • Flutter widget classes
  • BuildContext, the widget tree, and the element tree
  • Flutter development environment and tips

I imagine, because you’re reading this, that you’re at least intrigued by Flutter. By the end of this chapter, I hope you’ll be excited about it. In this chapter, I’ll walk you through the ins and outs of Flutter. I’ll show you how to use it and how it works under the hood. The goal of this chapter is to build a foundation. This is the plan for doing so:

  1. Take an in-depth look at the counter app, which is the app that’s generated when you start a new Flutter project with the CLI.
  2. Make the counter app more robust by adding some basic widgets.
  3. Spend some time talking about BuildContext, the widget tree, and elements. Understanding how this works is 90% of debugging Flutter errors.
  4. Learn tricks and tools that the Flutter team has built in to the SDK that makes development enjoyable.
Note

If Flutter isn’t installed on your machine yet, you can find installation instructions in the appendix. If you have trouble setting it up, look for additional help in the docs at https://flutter.dev/get-started.

3.1. Intro to the counter app

3.1.1. Flutter project structure

3.1.2. Anatomy of a Flutter app

3.1.3. Again, everything is a widget

3.1.4. The build method

3.1.5. The new and const constructors in Flutter

3.1.6. Hot reload

Using hot reload

3.2. Widgets: The widget tree, widget types, and the State object

3.2.1. Stateless widgets

3.2.2. Stateful widgets

Private values in Dart with an underscore

3.2.3. setState

3.2.4. initState

3.3. BuildContext

3.4. Enhancing the counter app with the most important widgets

3.4.1. RaisedButton

3.5. Favor composition in Flutter (over inheritance)

3.5.1. What is composition?

3.5.2. An example of composition in Flutter

3.6. Intro to layout in Flutter

3.6.1. Row and Column

3.6.2. Layout constraints in Flutter

3.6.3. RenderObject

sitemap