Chapter 4

Hello Again

IN THIS CHAPTER

Bullet Looking at functions in a Flutter app

Bullet Learning to type

Bullet Dealing with variables and other little things

♪ “Hello, hello again, sh-boom and hopin' we'll meet again.” ♪

—JAMES KEYES, CLAUDE FEASTER, CARL FEASTER, FLOYD F. MCRAE, AND JAMES EDWARDS, SUNG BY THE CHORDS, THE CREW-CUTS, STAN FREBERG, AND OTHERS, 1954

Chapter 3 is all about a simple Hello World program. Listing 4-1 shows one version of the code.

LISTING 4-1: Yet Another Look at the First Hello Program

import 'package:flutter/material.dart';main() => runApp(App0401());class App0401 extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( home: Material( child: Center(child: Text("Hello world!")), ), ); }}

In Chapter 3, you focused on the middle of the program — the MaterialApp and all the stuff inside it — while ignoring anything having to do with things called “functions.” This chapter continues the tour of a Hello World program and sets its sites on those “function” things.

Creating and Using a Function

Here's an experiment: Run the app whose code is shown in Listing 4-2.

LISTING 4-2: Words, Words, Words

import 'package:flutter/material.dart';main() => runApp(App0402()); ...

Get Coding All-in-One For Dummies, 2nd Edition 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.