shareScoreCard function
Captures a result widget (built temporarily in a hidden overlay right
before calling this) then opens the share sheet with levelText — same
pattern as shareBoardImage but with a separate file/caption because
this is a result card, not a board screenshot. Wire this to
VictoryCardTemplate (presentation/widgets/common/victory_card_template.dart)
— wrap it in a RepaintBoundary(key: ...) and pass that key here.
Implementation
Future<void> shareScoreCard({
required GlobalKey boundaryKey,
required String levelText,
BuildContext? sharePositionContext,
}) async {
// Computed before the `await` below — see `shareBoardImage`'s comment.
final sharePositionOrigin = _sharePositionOriginOf(sharePositionContext);
final png = await captureBoardPng(boundaryKey, overlayText: levelText);
if (png == null) return;
await SharePlus.instance.share(
ShareParams(
text: levelText,
files: [XFile.fromData(png, mimeType: 'image/png')],
fileNameOverrides: const ['roy_casual_kit_score_card.png'],
sharePositionOrigin: sharePositionOrigin,
),
);
}