2Creating a Hello World App

WHAT YOU WILL LEARN IN THIS CHAPTER

  • How to create a new Flutter mobile app
  • How to refresh the running app with hot reload
  • How to style the app with themes
  • When to use a stateless or stateful widget
  • How to add external packages

A great way to learn a new development language is to write a basic app. In programming, Hello World is the most basic program to write. It simply displays the words Hello World on the screen. In this chapter, you'll learn the main steps of how to develop this basic program as a Flutter app. Do not worry about understanding the code yet; I'll walk you through it step‐by‐step later in this book.

Writing this minimal example helps you learn the basic structure of a Flutter app, how to run the app on the iOS simulator and the Android emulator, and how to make changes to the code.

SETTING UP THE PROJECT

The initial project setup for each app is the same. I'm using Android Studio to create the sample apps in this book, but you can choose a different editor such as IntelliJ or Visual Studio Code. An overview of the process in Android Studio is as follows: you create a new Flutter project, select the Flutter application as the project type (template), and enter the project name. The Flutter software development kit (SDK) then creates the project for you, including creating a project directory with the same name as the project name. Within the project directory, the lib folder contains the main.dart file with the source code (in ...

Get Beginning Flutter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.