A bit of notification turn on reminder

This commit is contained in:
2026-03-01 05:45:23 +08:00
parent ec46c33c35
commit e91e7b43d2
9 changed files with 190 additions and 14 deletions
+44 -1
View File
@@ -1,4 +1,7 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../models/profile.dart';
@@ -299,9 +302,49 @@ final dashboardMetricsProvider = Provider<AsyncValue<DashboardMetrics>>((ref) {
);
});
class DashboardScreen extends StatelessWidget {
class DashboardScreen extends StatefulWidget {
const DashboardScreen({super.key});
@override
State<DashboardScreen> createState() => _DashboardScreenState();
}
class _DashboardScreenState extends State<DashboardScreen> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
final prefs = await SharedPreferences.getInstance();
final seen = prefs.getBool('has_seen_notif_showcase') ?? false;
if (!seen) {
if (!mounted) return;
await showDialog<void>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Never miss an update'),
content: const Text(
'Ensure notification sounds and vibration are enabled for important alerts.',
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
openAppSettings();
},
child: const Text('Open settings'),
),
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('Got it'),
),
],
),
);
await prefs.setBool('has_seen_notif_showcase', true);
}
});
}
@override
Widget build(BuildContext context) {
final realtime = ProviderScope.containerOf(