Skip to content

Commit 640e29d

Browse files
committed
Fix lint hint "Don't use 'BuildContext's across async gaps"
1 parent 8127a23 commit 640e29d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/alarm_manager_screen.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ class AlarmManagerScreen extends StatelessWidget {
77
const AlarmManagerScreen({super.key});
88

99
Future<void> _requestNotificationPermission(BuildContext context) async {
10+
// get a reference to the ScaffoldMessenger before calling async method
11+
final scaffoldMessenger = ScaffoldMessenger.of(context);
1012
final status = await Permission.notification.request();
13+
1114
if (status.isGranted) {
1215
await AlarmMethodChannel.scheduleAlarm();
1316
} else {
14-
ScaffoldMessenger.of(context).showSnackBar(
17+
scaffoldMessenger.showSnackBar(
1518
const SnackBar(
1619
content:
1720
Text('Notification permission is required to schedule alarms.'),

0 commit comments

Comments
 (0)