From cf3a04383845133482b4756f6ccf64b3926783e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Uek=C3=B6tter?= Date: Wed, 2 Oct 2024 19:43:01 +0200 Subject: [PATCH] Default to pixel ratio Resolves #205 --- packages/home_widget/lib/src/home_widget.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/home_widget/lib/src/home_widget.dart b/packages/home_widget/lib/src/home_widget.dart index 5183c8b..53cdc52 100644 --- a/packages/home_widget/lib/src/home_widget.dart +++ b/packages/home_widget/lib/src/home_widget.dart @@ -154,8 +154,11 @@ class HomeWidget { Widget widget, { required String key, Size logicalSize = const Size(200, 200), - double pixelRatio = 1, + double? pixelRatio, }) async { + pixelRatio ??= + PlatformDispatcher.instance.implicitView?.devicePixelRatio ?? 1; + /// finding the widget in the current context by the key. final RenderRepaintBoundary repaintBoundary = RenderRepaintBoundary(); @@ -174,7 +177,7 @@ class HomeWidget { ), configuration: ViewConfiguration( logicalConstraints: BoxConstraints.tight(logicalSize), - devicePixelRatio: 1.0, + devicePixelRatio: pixelRatio, ), ); @@ -193,9 +196,7 @@ class HomeWidget { child: Column( // image is center aligned mainAxisAlignment: MainAxisAlignment.center, - children: [ - widget, - ], + children: [widget], ), ), ).attachToRenderTree(buildOwner);