show static method
- BuildContext context, {
- required String changelog,
- String? lastSeenVersion,
- ChangelogStyle? style,
- String title = 'What\u2019s New',
- Widget bulletBuilder(
- String bullet
- Future<
void> onDismiss(- String newestVersion
- SeenVersionStore store = const SharedPrefsSeenStore(),
- bool autoPersist = true,
Shows the sheet and returns when dismissed. The newest version shown
is reported through onDismiss so the caller can persist it.
Implementation
static Future<void> show(
BuildContext context, {
required String changelog,
String? lastSeenVersion,
ChangelogStyle? style,
String title = 'What\u2019s New',
Widget Function(String bullet)? bulletBuilder,
Future<void> Function(String newestVersion)? onDismiss,
SeenVersionStore store = const SharedPrefsSeenStore(),
bool autoPersist = true,
}) async {
if (lastSeenVersion != null) {
final seen = await store.lastSeenVersion();
if (!context.mounted) return;
lastSeenVersion = seen ?? lastSeenVersion;
}
await showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
showDragHandle: true,
builder: (_) => FractionallySizedBox(
heightFactor: 0.85,
child: WhatsNewSheet(
changelog: changelog,
sinceVersion: lastSeenVersion,
style: style,
title: title,
bulletBuilder: bulletBuilder,
),
),
);
final entries = ChangelogParser.parse(changelog);
if (entries.isEmpty) return;
final newest = entries.reduce((a, b) => a.compareTo(b) >= 0 ? a : b);
if (!context.mounted) return;
if (autoPersist) {
await store.markSeen(newest.version);
} else {
await onDismiss?.call(newest.version);
}
}