fix(flutter): request notification permission proactively (TODO-041)

When user enables poke notifications, call requestPermission()
immediately so OS prompt appears on first enable, not lazily.
This commit is contained in:
Edison Jwa
2026-06-11 20:44:17 +09:00
parent ef19f4e7ce
commit 00e3fa7ad5
2 changed files with 23 additions and 3 deletions
@@ -1,13 +1,19 @@
import 'package:flutter/material.dart';
import '../l10n/generated/app_localizations.dart';
import '../services/poke_notification_service.dart';
import '../services/poke_preferences_service.dart';
import 'voice_settings_controls.dart';
class PokeNotificationSettingsDialog extends StatelessWidget {
const PokeNotificationSettingsDialog({super.key, required this.preferences});
const PokeNotificationSettingsDialog({
super.key,
required this.preferences,
required this.notificationService,
});
final PokePreferencesService preferences;
final PokeNotificationService notificationService;
@override
Widget build(BuildContext context) {
@@ -31,7 +37,15 @@ class PokeNotificationSettingsDialog extends StatelessWidget {
title: Text(l10n.pokeSettingsEnableLabel),
subtitle: Text(l10n.pokeSettingsEnableDescription),
value: enabled,
onChanged: (value) => preferences.setPokesEnabled(value),
onChanged: (value) async {
await preferences.setPokesEnabled(value);
// Request notification permission when enabling pokes
// so the OS prompt appears immediately rather than on
// the first poke event.
if (value) {
await notificationService.requestPermission();
}
},
),
),
const Divider(height: 24),