@@ -32,8 +32,7 @@ class _HomePageState extends State<HomePage> {
32
32
List <dynamic > _notifications = [];
33
33
34
34
_checkIfSetupDone () async {
35
- flutterLocalNotificationsPlugin =
36
- FlutterLocalNotificationsPlugin ();
35
+ flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin ();
37
36
if (await storage.read (key: "setup" ) != "done" ) {
38
37
await _showInfoDialogBox ();
39
38
bool result = await _getNotificationPermission ();
@@ -85,8 +84,10 @@ class _HomePageState extends State<HomePage> {
85
84
setState (() {
86
85
_notifications = result;
87
86
});
88
- String lastnotification = _notifications[0 ]['subject' ]['title' ];
89
- storage.write (key: 'lastnotification' , value: lastnotification);
87
+ if (_notifications.isNotEmpty) {
88
+ String lastnotification = _notifications[0 ]['subject' ]['title' ];
89
+ storage.write (key: 'lastnotification' , value: lastnotification);
90
+ }
90
91
} catch (_) {
91
92
_showError ();
92
93
}
@@ -104,7 +105,10 @@ class _HomePageState extends State<HomePage> {
104
105
Navigator .push (
105
106
context,
106
107
MaterialPageRoute (
107
- builder: (context) => SettingsPage (storage: storage, github: github,)));
108
+ builder: (context) => SettingsPage (
109
+ storage: storage,
110
+ github: github,
111
+ )));
108
112
}
109
113
110
114
@override
@@ -126,11 +130,11 @@ class _HomePageState extends State<HomePage> {
126
130
foregroundColor: Colors .white,
127
131
title: const Text ('GitAlerts' ),
128
132
actions: [
129
- IconButton (
130
- icon: const Icon (Icons .settings),
131
- onPressed: () => _goToSettingsPage (),
132
- ),
133
- ],
133
+ IconButton (
134
+ icon: const Icon (Icons .settings),
135
+ onPressed: () => _goToSettingsPage (),
136
+ ),
137
+ ],
134
138
),
135
139
backgroundColor: Colors .grey,
136
140
body: RefreshIndicator (
@@ -149,7 +153,7 @@ class _HomePageState extends State<HomePage> {
149
153
final notification = _notifications[index];
150
154
final repoFullName = notification['repository' ]['full_name' ];
151
155
final notificationText = notification['subject' ]['title' ];
152
-
156
+
153
157
return Card (
154
158
margin: const EdgeInsets .all (6.0 ),
155
159
child: Column (
@@ -159,13 +163,19 @@ class _HomePageState extends State<HomePage> {
159
163
padding: const EdgeInsets .all (9.0 ),
160
164
child: Text (
161
165
repoFullName,
162
- style: const TextStyle (fontWeight: FontWeight .bold, fontSize: 18.0 ,),
166
+ style: const TextStyle (
167
+ fontWeight: FontWeight .bold,
168
+ fontSize: 18.0 ,
169
+ ),
163
170
),
164
171
),
165
172
Padding (
166
173
padding: const EdgeInsets .all (18.0 ),
167
- child: Text (notificationText,
168
- style: const TextStyle (fontSize: 16.0 ,),
174
+ child: Text (
175
+ notificationText,
176
+ style: const TextStyle (
177
+ fontSize: 16.0 ,
178
+ ),
169
179
),
170
180
),
171
181
],
0 commit comments