showWelcomeSheetIfNeeded method
Future<void>
showWelcomeSheetIfNeeded(
- BuildContext context, {
- required WelcomeBrief brief,
- required String productName,
- VoidCallback? onLater,
Show TesterWelcomeSheet once per app version. The host passes
in a TesterBrief (release notes + concrete tasks); the sheet
renders, the tester taps "Test starten" — we persist
testerpaykit_welcome_shown_<version> so the same version
doesn't re-prompt on the next launch.
Subsequent app versions get a fresh prompt. Distinct from showOnboardingIfNeeded which only runs once per device for mic + screenshot consent.
productName is rendered in the AppBar ("Bonblick — Tester-Welcome").
onLater — when supplied, a "Später" button is shown alongside
"Test starten"; tap pops the sheet without persisting (the sheet
will re-show on the next launch). When null, only "Test starten"
is offered.
Implementation
Future<void> showWelcomeSheetIfNeeded(
BuildContext context, {
required WelcomeBrief brief,
required String productName,
VoidCallback? onLater,
}) async {
final prefs = await SharedPreferences.getInstance();
final key = '$_kWelcomeShownPrefix${brief.appVersion}';
final done = prefs.getBool(key) ?? false;
if (done) return;
if (!context.mounted) return;
await Navigator.of(context, rootNavigator: true).push(
MaterialPageRoute<void>(
builder: (_) => TesterWelcomeSheet(
brief: brief,
productName: productName,
onStart: () async {
// Persist only on Start — "Später" leaves the flag off
// so the sheet returns next launch.
await prefs.setBool(key, true);
},
onLater: onLater,
),
fullscreenDialog: true,
),
);
}