Files
pluriwave/lib/servicios/servicio_bienvenida.dart

33 lines
1.2 KiB
Dart

import 'package:shared_preferences/shared_preferences.dart';
/// WU17b: persists whether the first-run welcome screen (`PantallaBienvenida`,
/// `onboarding-welcome` spec) has already been shown, so it renders once
/// rather than on every launch.
///
/// Same injectable-`SharedPreferences`, versioned-key convention as
/// `ServicioContenidoApp` (S3-R4) — but a plain one-time boolean flag, since
/// this welcome screen is a single first-impression surface, not something
/// that re-triggers per app version the way the "what's new" onboarding
/// dialog does.
class ServicioBienvenida {
ServicioBienvenida({SharedPreferences? prefs}) : _prefs = prefs;
static const _keyBienvenidaVista = 'pluri_bienvenida_vista_v1';
final SharedPreferences? _prefs;
/// Injected startup instance (S3-R4); getInstance() is only a fallback.
Future<SharedPreferences> _resolverPrefs() async =>
_prefs ?? SharedPreferences.getInstance();
Future<bool> debeMostrarBienvenida() async {
final prefs = await _resolverPrefs();
return !(prefs.getBool(_keyBienvenidaVista) ?? false);
}
Future<void> marcarBienvenidaVista() async {
final prefs = await _resolverPrefs();
await prefs.setBool(_keyBienvenidaVista, true);
}
}