1
+ import 'package:flutter/foundation.dart' ;
1
2
import 'package:flutter/material.dart' ;
2
3
import 'package:flutter/services.dart' ;
3
4
import 'package:flutter_line_sdk/flutter_line_sdk.dart' ;
@@ -6,8 +7,10 @@ import '../theme.dart';
6
7
import '../widget/user_info_widget.dart' ;
7
8
8
9
class HomePage extends StatefulWidget {
10
+ const HomePage ({Key ? key}) : super (key: key);
11
+
9
12
@override
10
- _HomePageState createState () => _HomePageState ();
13
+ State < StatefulWidget > createState () => _HomePageState ();
11
14
}
12
15
13
16
class _HomePageState extends State <HomePage >
@@ -17,7 +20,7 @@ class _HomePageState extends State<HomePage>
17
20
StoredAccessToken ? _accessToken;
18
21
bool _isOnlyWebLogin = false ;
19
22
20
- final Set <String > _selectedScopes = Set . from ([ 'profile' ]) ;
23
+ final Set <String > _selectedScopes = { 'profile' } ;
21
24
22
25
@override
23
26
bool get wantKeepAlive => true ;
@@ -38,7 +41,9 @@ class _HomePageState extends State<HomePage>
38
41
userProfile = await LineSDK .instance.getProfile ();
39
42
}
40
43
} on PlatformException catch (e) {
41
- print (e.message);
44
+ if (kDebugMode) {
45
+ print (e.message);
46
+ }
42
47
}
43
48
44
49
if (! mounted) return ;
@@ -60,11 +65,15 @@ class _HomePageState extends State<HomePage>
60
65
_configCard (),
61
66
Expanded (
62
67
child: Center (
63
- child: ElevatedButton (
64
- child: Text ('Sign In' ),
65
- onPressed: _signIn,
66
- style: ElevatedButton .styleFrom (
67
- backgroundColor: accentColor, foregroundColor: textColor))),
68
+ child: ElevatedButton (
69
+ onPressed: _signIn,
70
+ style: ElevatedButton .styleFrom (
71
+ backgroundColor: accentColor,
72
+ foregroundColor: textColor,
73
+ ),
74
+ child: const Text ('Sign In' ),
75
+ ),
76
+ ),
68
77
),
69
78
],
70
79
),
@@ -82,14 +91,12 @@ class _HomePageState extends State<HomePage>
82
91
Widget _configCard () {
83
92
return Card (
84
93
child: Padding (
85
- padding: EdgeInsets .all (15.0 ),
94
+ padding: const EdgeInsets .all (15.0 ),
86
95
child: Column (
87
96
crossAxisAlignment: CrossAxisAlignment .start,
88
97
children: < Widget > [
89
98
_scopeListUI (),
90
- SizedBox (
91
- height: 10.0 ,
92
- ),
99
+ const SizedBox (height: 10.0 ),
93
100
Row (
94
101
children: < Widget > [
95
102
Checkbox (
@@ -101,7 +108,7 @@ class _HomePageState extends State<HomePage>
101
108
});
102
109
},
103
110
),
104
- Text ('only Web Login' ),
111
+ const Text ('only Web Login' ),
105
112
],
106
113
),
107
114
],
@@ -113,7 +120,7 @@ class _HomePageState extends State<HomePage>
113
120
Widget _scopeListUI () => Column (
114
121
crossAxisAlignment: CrossAxisAlignment .start,
115
122
children: < Widget > [
116
- Text ('Scopes: ' ),
123
+ const Text ('Scopes: ' ),
117
124
Wrap (
118
125
children:
119
126
_scopes.map <Widget >((scope) => _buildScopeChip (scope)).toList (),
@@ -126,7 +133,7 @@ class _HomePageState extends State<HomePage>
126
133
child: ChipTheme (
127
134
data: ChipTheme .of (context).copyWith (brightness: Brightness .dark),
128
135
child: FilterChip (
129
- label: Text (scope, style: TextStyle (color: textColor)),
136
+ label: Text (scope, style: const TextStyle (color: textColor)),
130
137
selectedColor: accentColor,
131
138
backgroundColor: secondaryBackgroundColor,
132
139
selected: _selectedScopes.contains (scope),
@@ -158,6 +165,7 @@ class _HomePageState extends State<HomePage>
158
165
_accessToken = accessToken;
159
166
});
160
167
} on PlatformException catch (e) {
168
+ if (! mounted) return ;
161
169
_showDialog (context, e.toString ());
162
170
}
163
171
}
@@ -171,7 +179,9 @@ class _HomePageState extends State<HomePage>
171
179
_accessToken = null ;
172
180
});
173
181
} on PlatformException catch (e) {
174
- print (e.message);
182
+ if (kDebugMode) {
183
+ print (e.message);
184
+ }
175
185
}
176
186
}
177
187
@@ -183,11 +193,12 @@ class _HomePageState extends State<HomePage>
183
193
content: Text (text),
184
194
actions: < Widget > [
185
195
TextButton (
186
- child: Text ('Close' ),
187
- onPressed: () {
188
- Navigator .of (context).pop ();
189
- },
190
- style: TextButton .styleFrom (foregroundColor: accentColor)),
196
+ onPressed: () {
197
+ Navigator .of (context).pop ();
198
+ },
199
+ style: TextButton .styleFrom (foregroundColor: accentColor),
200
+ child: const Text ('Close' ),
201
+ ),
191
202
],
192
203
);
193
204
},
0 commit comments