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...