Chapter 4

Hello Again

IN THIS CHAPTER

check Looking at functions in a Flutter app

check Learning to type

check 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. For convenience, I copy one version of the code here, in Listing 4-1.

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, I have you concentrate on the middle of the program — the MaterialApp and all the stuff inside it. I let you gleefully ignore the other parts of the program. In particular, I let you ignore 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 ...

Get Flutter For Dummies 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.