-
Notifications
You must be signed in to change notification settings - Fork 149
Open
Description
ScreenshotController.captureFromWidget() doesn't provide context injected dependencies to its descendants. This makes this feature unusable without recreating entire sets of dependencies or building custom dependency/context portals.
What would an improved experience look like here?
related issues:
Current workaround example:
final controller = ScreenshotController();
final img = await controller.captureFromWidget(
buildScreenshot(context),
context: context,
pixelRatio: 2,
);
Widget buildScreenshot(BuildContext context) {
return LocalizationsPortal( // this is needed otherwise children can't get access to localization
context: context,
child: _ScreenshotBase(meal: widget.meal),
);
}
class LocalizationsPortal extends StatelessWidget {
const LocalizationsPortal({
super.key,
required this.child,
required this.context,
});
final BuildContext context;
final Widget child;
@override
Widget build(BuildContext context) {
return Localizations(
locale: Localizations.localeOf(this.context),
delegates: localizationsDelegates,
child: child,
);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels