Part 1
Getting Ready
IN THIS PART …
Working through the nuts-and-bolts of mobile app development
Prepping your development computer
Running sample programs
Chapter 1
What Is Flutter?
IN THIS CHAPTER
Some boring terminology :-( Several years ago, I won a smartphone in a raffle at an app developer conference. What a joy it was to win something! The experience made me feel that the entire cosmos favored me. Every time I used that phone, I felt like a big shot.
Eventually, the phone’s battery became so weak that I had to charge it every hour. I didn’t realize that the phone was still under warranty, so I tried to replace the phone’s battery myself. I bought a new battery from an online vendor. The instructions told me how to take the case apart, unhook the circuit connections, and remove the old battery from its cradle.
Everything went nicely until the part about removing the old battery. The instructions said to pull on a little tab, but I couldn’t find a tab. So, I tried for several minutes to get a grip on the battery.
The battery wasn’t budging, so I found a little screwdriver and tried to pry the battery from its tight surroundings. That’s when I heard a pop, smelled smoke, and realized that the phone’s battery had caught fire.
Fast-forward to the next afternoon. I was wandering past an electronics shop, so I went in and asked whether the shopkeeper might be able to fix my phone. “Yes,” he said. “Bring it in the next time you’re in the neighborhood. I can fix any phone.”
You should have seen the look on the shopkeeper’s face when, later that day, I brought in the charred, bent-up, barely recognizable phone. I would have included a picture in this book but, alas, I couldn’t take a picture. I had no phone.
I still remember this phone battery story from beginning to end. I remember the joy of winning a free phone, the shock of seeing it go up in flames, and the look of horror on the shopkeeper’s face. But my most powerful memory comes from the moment I opened the phone’s case: Inside that little case, I saw enough circuitry to make me dizzy. Having done some electrical work in my own home, I’d handled thick 10-gauge wires and hefty 220-volt connectors. I had replaced desktop computers’ sound cards, laptop computers’ hard drives, and the SSD inside a tightly packed MacBook Air. But this smartphone was amazing. The circuit board looked like a microchip in its own right. The connectors were so tiny that I wondered how signals could reliably squeeze through them.
No doubt about it: Mobile phones are complicated beasts. So how do they work? What makes them tick? What’s going on inside each of those remarkable gadgets?
Hardware and Software (Things You May Already Know)
A mobile phone is really a small computer. And, like any computer, a mobile phone operates on several layers. Figure 1-1 shows you a few of those layers.
Hardware is the stuff you can touch. It’s the bottom layer of the diagram in Figure 1-1. Hardware consists of items like circuitry, memory, and the battery.
Electrical signals that travel along the hardware’s circuits make the hardware do what you want it to do. These signals encode instructions. Taken as a whole, these instructions are called software.
When people create software, they don’t describe each electrical signal that travels through the hardware’s circuitry. Instead, people write source code — instructions that look something like English-language instructions. One source code instruction can be shorthand for hundreds or thousands of electrical signals.
A collection of source code instructions that perform a particular task (word processing, web browsing, managing a smart thermostat, or whatever) is called a program. A person who writes these instructions is a programmer or — a fancier-sounding term — a developer. The person who runs a program on their own device is a user.
Just as people communicate using many spoken languages, programmers write source code using many programming languages. If you create iPhone apps, you probably write code in either the Swift language or the Objective-C language. If you create Android apps, you’re likely to write code in either Kotlin or Java.
When you create a Flutter app, you write code in the Dart programming language. Here’s a complete Dart language program:
main() => print('Hello');
This program displays the word Hello on the screen. It’s not very useful, but please be patient. This is only Chapter 1!
Figure 1-1 distinguishes between two kinds of software:
-
Operating system (OS) software runs whenever the device is turned on.
OS software manages the device and provides ways for the user to interact with the device. Devices made by Apple, such as iPhones and iPads, run the iOS operating system. Android phones and tablets run the Android operating system (of course).
-
Application programs do the work that users want done.
Apps to make phone calls, apps to read email, calendar apps, web browsers, and games are examples of application programs. As a Flutter developer, your job is to create application programs.
By one estimate, the popular operating system named Linux consists of nearly 28 million instructions. No one can deal with that much code, so operating systems are divided into layers of their own. Figure 1-1 shows only four of a typical operating system’s many layers:
-
A kernel performs the operating system’s most fundamental tasks.
The kernel schedules apps to be run, manages a device’s memory and files, provides access to input and output, and does man...