Foreword |
|
xv | |
Preface |
|
xvii | |
Acknowledgments |
|
xix | |
About This Book |
|
xxi | |
About The Author |
|
xxiv | |
About The Cover Illustration |
|
xxv | |
Part 1 Meet Flutter |
|
1 | (94) |
|
|
3 | (21) |
|
1.1 Why does Flutter use Dart? |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
1.4 Who should be using Flutter? |
|
|
6 | (2) |
|
Teams, project leads, and CTOs |
|
|
6 | (1) |
|
|
7 | (1) |
|
Code school students and recent CS grads |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
8 | (1) |
|
1.6 Other mobile development options |
|
|
8 | (2) |
|
Native development (iOS and Android) |
|
|
8 | (1) |
|
Cross-platform JavaScript options |
|
|
8 | (2) |
|
1.7 The immediate benefits of Flutter |
|
|
10 | (2) |
|
|
10 | (1) |
|
|
10 | (1) |
|
Write once, test once, deploy everywhere |
|
|
10 | (1) |
|
|
11 | (1) |
|
Productivity and collaboration |
|
|
11 | (1) |
|
|
11 | (1) |
|
The bottom line: Is Flutter for you? |
|
|
11 | (1) |
|
1.8 Future benefits of Flutter: Web apps and desktop apps |
|
|
12 | (1) |
|
1.9 A brief intro to how Flutter works |
|
|
12 | (6) |
|
|
14 | (1) |
|
Composing UI with widgets |
|
|
15 | (1) |
|
|
16 | (2) |
|
1.10 Flutter rendering: Under the hood |
|
|
18 | (4) |
|
Composing the widget tree and layout |
|
|
20 | (1) |
|
|
21 | (1) |
|
|
22 | (1) |
|
|
22 | (2) |
|
|
24 | (30) |
|
|
25 | (4) |
|
Anatomy of a Dart program |
|
|
26 | (1) |
|
|
26 | (2) |
|
|
28 | (1) |
|
2.2 Common programming concepts in Dart |
|
|
29 | (7) |
|
Intro to Dart's type system |
|
|
30 | (2) |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
34 | (1) |
|
|
34 | (2) |
|
|
36 | (5) |
|
|
37 | (1) |
|
|
37 | (1) |
|
|
38 | (2) |
|
|
40 | (1) |
|
|
41 | (4) |
|
Anatomy of a Dart function |
|
|
41 | (1) |
|
|
42 | (1) |
|
|
43 | (1) |
|
Advanced function concepts |
|
|
43 | (2) |
|
|
45 | (1) |
|
2.5 Object-oriented programming (in Dart) |
|
|
45 | (9) |
|
|
46 | (2) |
|
|
48 | (1) |
|
|
49 | (1) |
|
Factories and named constructors |
|
|
50 | (1) |
|
|
51 | (3) |
|
|
54 | (41) |
|
3.1 Intro to the counter app |
|
|
55 | (5) |
|
Flutter project structure |
|
|
56 | (1) |
|
|
56 | (1) |
|
Again, everything is a widget |
|
|
57 | (1) |
|
|
58 | (1) |
|
The new and const constructors in Flutter |
|
|
59 | (1) |
|
|
59 | (1) |
|
3.2 Widgets: The widget tree, widget types, and the State object |
|
|
60 | (7) |
|
|
61 | (1) |
|
|
62 | (2) |
|
|
64 | (2) |
|
|
66 | (1) |
|
|
67 | (1) |
|
3.4 Enhancing the counter app with the most important widgets |
|
|
68 | (1) |
|
|
68 | (1) |
|
3.5 Favor composition in Flutter (over inheritance) |
|
|
69 | (3) |
|
|
69 | (2) |
|
An example of composition in Flutter |
|
|
71 | (1) |
|
3.6 Intro to layout in Flutter |
|
|
72 | (11) |
|
|
72 | (2) |
|
Layout constraints in Flutter |
|
|
74 | (1) |
|
|
74 | (1) |
|
RenderObject and constraints |
|
|
75 | (1) |
|
RenderBoxes and layout errors |
|
|
75 | (1) |
|
|
76 | (2) |
|
Icons and the FloatingActionButton |
|
|
78 | (2) |
|
|
80 | (1) |
|
|
81 | (2) |
|
|
83 | (9) |
|
|
85 | (1) |
|
Exploring the element tree with an example |
|
|
86 | (2) |
|
The element tree and State objects |
|
|
88 | (2) |
|
|
90 | (2) |
|
|
92 | (3) |
Part 2 Flutter User Interaction, Styles, And Animations |
|
95 | (94) |
|
4 Flutter UI: Important widgets, themes, and layout |
|
|
97 | (32) |
|
4.1 Setting up and configuring a Flutter app |
|
|
99 | (3) |
|
Configuration: pubspec.yaml and main.dart |
|
|
99 | (2) |
|
|
101 | (1) |
|
4.2 Structural widgets and more configuration |
|
|
102 | (6) |
|
|
102 | (2) |
|
|
104 | (2) |
|
|
106 | (2) |
|
4.3 Styling and themes in Flutter |
|
|
108 | (4) |
|
|
108 | (2) |
|
Media Query and the of method |
|
|
110 | (1) |
|
|
111 | (1) |
|
4.4 Common layout and UI widgets |
|
|
112 | (14) |
|
|
112 | (4) |
|
|
116 | (6) |
|
|
122 | (4) |
|
4.5 ListView and builders |
|
|
126 | (3) |
|
5 User interaction: Forms and gestures |
|
|
129 | (29) |
|
5.1 User interaction and gestures |
|
|
130 | (6) |
|
The GestureDetector widget |
|
|
130 | (1) |
|
GestureDetector in practice |
|
|
131 | (3) |
|
|
134 | (2) |
|
|
136 | (5) |
|
|
137 | (1) |
|
|
138 | (1) |
|
The structure of the AddCityPage form |
|
|
138 | (2) |
|
Implementing the form in the weather app |
|
|
140 | (1) |
|
|
141 | (6) |
|
|
142 | (1) |
|
The DropdownFormButton widget |
|
|
143 | (3) |
|
|
146 | (1) |
|
5.4 Form UI and working with focus nodes |
|
|
147 | (4) |
|
|
147 | (2) |
|
Improving the UI with FocusNodes |
|
|
149 | (2) |
|
5.5 Managing form state with form methods |
|
|
151 | (7) |
|
|
152 | (1) |
|
|
153 | (2) |
|
|
155 | (3) |
|
6 Pushing pixels: Flutter animations and using the canvas |
|
|
158 | (31) |
|
6.1 Introducing Flutter animations |
|
|
159 | (13) |
|
|
160 | (1) |
|
|
161 | (1) |
|
|
162 | (1) |
|
|
162 | (1) |
|
|
163 | (3) |
|
Implementing the animation controller and tween for the background |
|
|
166 | (6) |
|
6.2 CustomPainter and the canvas |
|
|
172 | (7) |
|
The shapes used to make up the clouds |
|
|
173 | (1) |
|
Defining the CustomPainter and the Paint object |
|
|
173 | (2) |
|
The CustomPainter paint method |
|
|
175 | (4) |
|
6.3 Staggered animations, TweenSequence, and built-in animations |
|
|
179 | (8) |
|
Creating a custom animation state class |
|
|
179 | (3) |
|
Built-in animation widgets: SlideTransition |
|
|
182 | (2) |
|
Building animations for the Clouds widget |
|
|
184 | (1) |
|
|
185 | (2) |
|
6.4 Reusable custom color transition widgets |
|
|
187 | (2) |
Part 3 State Management And Asynchronous Dart |
|
189 | (76) |
|
7 Flutter routing in depth |
|
|
191 | (21) |
|
|
192 | (1) |
|
|
192 | (1) |
|
|
193 | (1) |
|
7.2 Declarative routing and named routes |
|
|
193 | (11) |
|
|
194 | (1) |
|
Navigating to named routes |
|
|
195 | (2) |
|
MaterialDrawer widget and the full menu |
|
|
197 | (1) |
|
Menu items and the appropriate widgets: List View and Listltems |
|
|
198 | (3) |
|
NavigatorObserver: Highlighting the active route with RouteAware |
|
|
201 | (3) |
|
|
204 | (5) |
|
|
204 | (1) |
|
showSnackBar, showBottomSheet, and the like |
|
|
205 | (4) |
|
|
209 | (3) |
|
8 Flutter state management |
|
|
212 | (24) |
|
8.1 Deep dive into StatefulWidgets |
|
|
213 | (3) |
|
The widget tree and the element tree |
|
|
213 | (1) |
|
The StatefulWidget lifecycle and when to do what |
|
|
214 | (2) |
|
8.2 Pure Flutter state management: The InheritedWidget |
|
|
216 | (9) |
|
Creating a Central Store wth an InheritedWidget/StatefulWidget team |
|
|
218 | (1) |
|
The inheritFromWidget0fExactType and of methods |
|
|
218 | (4) |
|
Use the of method to lift up state |
|
|
222 | (2) |
|
State management patterns beyond Flutter |
|
|
224 | (1) |
|
8.3 Blocs: Business Logic Components |
|
|
225 | (11) |
|
|
227 | (1) |
|
Implementing the bloc architecture |
|
|
228 | (3) |
|
Intro to streams and async Dart |
|
|
231 | (1) |
|
Implementing streams in the CartBloc |
|
|
232 | (4) |
|
9 Async Dart and Flutter and infinite scrolling |
|
|
236 | (29) |
|
|
237 | (5) |
|
|
237 | (2) |
|
|
239 | (1) |
|
Catching errors with futures |
|
|
240 | (1) |
|
Catching errors with try and catch |
|
|
241 | (1) |
|
9.2 Sinks and streams (and StreamControllers) |
|
|
242 | (8) |
|
Anatomy of the observer pattern with Dart streams |
|
|
243 | (1) |
|
|
243 | (2) |
|
|
245 | (2) |
|
|
247 | (3) |
|
9.3 Using streams in blocs |
|
|
250 | (4) |
|
Blocs use inputs and outputs |
|
|
250 | (3) |
|
Implementing a bloc input |
|
|
253 | (1) |
|
9.4 Async Flutter: StreamBuilder |
|
|
254 | (1) |
|
9.5 Infinite and custom scrollable widgets |
|
|
255 | (12) |
|
CustomScrollView and slivers |
|
|
256 | (1) |
|
Catalog widget scroll view |
|
|
256 | (4) |
|
|
260 | (1) |
|
|
260 | (1) |
|
|
261 | (4) |
Part 4 Beyond Foundations |
|
265 | (48) |
|
10 Working with data: HTTP, Firestore, and JSON |
|
|
267 | (25) |
|
|
268 | (2) |
|
|
269 | (1) |
|
|
269 | (1) |
|
|
270 | (11) |
|
|
271 | (4) |
|
Auto-generated JSON serialization |
|
|
275 | (1) |
|
|
275 | (2) |
|
Bringing it all together in the UI |
|
|
277 | (4) |
|
10.3 Working with Firebase in Flutter |
|
|
281 | (7) |
|
|
282 | (1) |
|
Create a Firestore project |
|
|
283 | (1) |
|
|
283 | (3) |
|
Add Firebase to your pubspec |
|
|
286 | (1) |
|
|
286 | (2) |
|
10.4 Dependency injection |
|
|
288 | (4) |
|
|
292 | (21) |
|
|
293 | (17) |
|
|
293 | (4) |
|
Using mockito to test methods that need external dependencies |
|
|
297 | (3) |
|
|
300 | (3) |
|
Flutter integration tests |
|
|
303 | (4) |
|
Performance profiling integration tests |
|
|
307 | (3) |
|
11.2 Accessibility with the semantics widgets |
|
|
310 | (1) |
|
11.3 Next steps with Flutter |
|
|
311 | (2) |
Appendix A Installation: Dart2 |
|
313 | (5) |
Appendix B The Pub package manager |
|
318 | (3) |
Appendix C Rutter for web developers |
|
321 | (3) |
Appendix D Rutter for iOS developers |
|
324 | (4) |
Appendix E Flutter for Android developers |
|
328 | (3) |
Index |
|
331 | |