Chapter 4. Flutter UI: Important widgets, themes, and layout

 

This chapter covers

  • Starting your first Flutter app
  • Layout widgets
  • Themes and styling
  • Custom form elements
  • Builder patterns

Flutter isn’t just a framework. It’s a complete SDK. And perhaps the most exciting piece of this SDK to me, as a web developer, is the massive library of built-in widgets that make building the frontend of your mobile app easy.

This chapter and the following two are all about the user interface (UI) and making an app beautiful. This chapter includes exploring some of the widgets built into Flutter, layout, styling, and more. In the following chapters, I’ll go a bit further into the UI and talk about forms and user input, as well as animations. Figure 4.1 shows the app I’ll use to explain the Flutter UI in the next few chapters.

Figure 4.1. Screenshots of the weather app

In this chapter, in particular, we’ll look at these high-level categories:

  • Structural widgets that outline the app.
  • Themes and styling, which this app is heavy on. We’ll set the custom color scheme and look at the MediaQuery class to help with styling.
  • Widgets that help with layout. This broad category includes building-block widgets like Table, Stack, and BoxConstraint, as well as some fantastic convenience widgets like TabBar, which provide features for free.
  • Additional layout widgets, specifically ListView. This widget can be scrollable and uses something called the builder pattern in Flutter.

4.1. Setting up and configuring a Flutter app

4.1.1. Configuration: pubspec.yaml and main.dart

4.1.2. SystemChrome

4.2. Structural widgets and more configuration

4.2.1. MaterialApp widget

4.2.2. The Scaffold widget

4.2.3. AppBar widget

Named imports in Dart

4.3. Styling and themes in Flutter

4.3.1. Theme widget

Summary

sitemap