5
5
import 'package:flutter/material.dart' ;
6
6
import 'package:flutter_module_books/api.dart' ;
7
7
8
- void main () => runApp (MyApp ());
8
+ void main () => runApp (const MyApp ());
9
9
10
10
class MyApp extends StatelessWidget {
11
+ const MyApp ({Key key}) : super (key: key);
12
+
11
13
@override
12
14
Widget build (BuildContext context) {
13
15
return MaterialApp (
14
16
theme: ThemeData (
15
17
primaryColor: const Color (0xff6200ee ),
16
18
),
17
- home: BookDetail (),
19
+ home: const BookDetail (),
18
20
);
19
21
}
20
22
}
@@ -37,7 +39,7 @@ class FlutterBookApiHandler extends FlutterBookApi {
37
39
}
38
40
39
41
class BookDetail extends StatefulWidget {
40
- const BookDetail ({this .hostApi, this .flutterApi} );
42
+ const BookDetail ({this .hostApi, this .flutterApi, Key key}) : super (key : key );
41
43
42
44
// These are the outgoing and incoming APIs that are here for injection for
43
45
// tests.
@@ -73,7 +75,7 @@ class _BookDetailState extends State<BookDetail> {
73
75
FlutterBookApi .setup (FlutterBookApiHandler (
74
76
// The `FlutterBookApi` just has one method. Just give a closure for that
75
77
// method to the handler class.
76
- (Book book) {
78
+ (book) {
77
79
setState (() {
78
80
// This book model is what we're going to return to Kotlin eventually.
79
81
// Keep it bound to the UI.
@@ -107,9 +109,9 @@ class _BookDetailState extends State<BookDetail> {
107
109
Widget build (BuildContext context) {
108
110
return Scaffold (
109
111
appBar: AppBar (
110
- title: Text ('Book Details' ),
112
+ title: const Text ('Book Details' ),
111
113
leading: IconButton (
112
- icon: Icon (Icons .clear),
114
+ icon: const Icon (Icons .clear),
113
115
// Pressing clear cancels the edit and leaves the activity without
114
116
// modification.
115
117
onPressed: () {
@@ -119,7 +121,7 @@ class _BookDetailState extends State<BookDetail> {
119
121
),
120
122
actions: [
121
123
IconButton (
122
- icon: Icon (Icons .check),
124
+ icon: const Icon (Icons .check),
123
125
// Pressing save sends the updated book to the platform.
124
126
onPressed: () {
125
127
hostApi.finishEditingBook (book);
@@ -131,54 +133,54 @@ class _BookDetailState extends State<BookDetail> {
131
133
body: book == null
132
134
// Draw a spinner until the platform gives us the book to show details
133
135
// for.
134
- ? Center (child: CircularProgressIndicator ())
136
+ ? const Center (child: CircularProgressIndicator ())
135
137
: Focus (
136
138
focusNode: textFocusNode,
137
139
child: ListView (
138
- padding: EdgeInsets .all (24 ),
140
+ padding: const EdgeInsets .all (24 ),
139
141
children: [
140
142
TextField (
141
143
controller: titleTextController,
142
- decoration: InputDecoration (
144
+ decoration: const InputDecoration (
143
145
border: OutlineInputBorder (),
144
146
filled: true ,
145
147
hintText: "Title" ,
146
148
labelText: "Title" ,
147
149
),
148
150
),
149
- SizedBox (height: 24 ),
151
+ const SizedBox (height: 24 ),
150
152
TextField (
151
153
controller: subtitleTextController,
152
154
maxLines: 2 ,
153
- decoration: InputDecoration (
155
+ decoration: const InputDecoration (
154
156
border: OutlineInputBorder (),
155
157
filled: true ,
156
158
hintText: "Subtitle" ,
157
159
labelText: "Subtitle" ,
158
160
),
159
161
),
160
- SizedBox (height: 24 ),
162
+ const SizedBox (height: 24 ),
161
163
TextField (
162
164
controller: authorTextController,
163
- decoration: InputDecoration (
165
+ decoration: const InputDecoration (
164
166
border: OutlineInputBorder (),
165
167
filled: true ,
166
168
hintText: "Author" ,
167
169
labelText: "Author" ,
168
170
),
169
171
),
170
- SizedBox (height: 32 ),
171
- Divider (),
172
+ const SizedBox (height: 32 ),
173
+ const Divider (),
172
174
Center (
173
175
child: Padding (
174
176
padding: const EdgeInsets .all (8.0 ),
175
177
child: Text (
176
178
'${book .pageCount } pages ~ published ${book .publishDate }' ),
177
179
),
178
180
),
179
- Divider (),
180
- SizedBox (height: 32 ),
181
- Center (
181
+ const Divider (),
182
+ const SizedBox (height: 32 ),
183
+ const Center (
182
184
child: Text (
183
185
'BOOK DESCRIPTION' ,
184
186
style: TextStyle (
@@ -188,7 +190,7 @@ class _BookDetailState extends State<BookDetail> {
188
190
),
189
191
),
190
192
),
191
- SizedBox (height: 12 ),
193
+ const SizedBox (height: 12 ),
192
194
Text (
193
195
book.summary,
194
196
style: TextStyle (color: Colors .grey.shade600, height: 1.24 ),
0 commit comments