Showing
3 changed files
with
16 additions
and
5 deletions
@@ -67,8 +67,7 @@ class PdfPreviewData extends ChangeNotifier { | @@ -67,8 +67,7 @@ class PdfPreviewData extends ChangeNotifier { | ||
67 | PdfPageFormat get actualPageFormat => _onComputeActualPageFormat(); | 67 | PdfPageFormat get actualPageFormat => _onComputeActualPageFormat(); |
68 | 68 | ||
69 | String get localPageFormat { | 69 | String get localPageFormat { |
70 | - final wbi = WidgetsBinding.instance; | ||
71 | - final locale = wbi.window.locale; | 70 | + final locale = WidgetsBinding.instance.platformDispatcher.locale; |
72 | final cc = locale.countryCode ?? 'US'; | 71 | final cc = locale.countryCode ?? 'US'; |
73 | 72 | ||
74 | if (cc == 'US' || cc == 'CA' || cc == 'MX') { | 73 | if (cc == 'US' || cc == 'CA' || cc == 'MX') { |
@@ -70,6 +70,12 @@ class PdfRasterImage extends ImageProvider<PdfRaster> { | @@ -70,6 +70,12 @@ class PdfRasterImage extends ImageProvider<PdfRaster> { | ||
70 | return OneFrameImageStreamCompleter(_loadAsync()); | 70 | return OneFrameImageStreamCompleter(_loadAsync()); |
71 | } | 71 | } |
72 | 72 | ||
73 | + // Flutter 3.9 | ||
74 | + // @override | ||
75 | + // ImageStreamCompleter loadImage(PdfRaster key, ImageDecoderCallback decode) { | ||
76 | + // return OneFrameImageStreamCompleter(_loadAsync()); | ||
77 | + // } | ||
78 | + | ||
73 | @override | 79 | @override |
74 | Future<PdfRaster> obtainKey(ImageConfiguration configuration) async { | 80 | Future<PdfRaster> obtainKey(ImageConfiguration configuration) async { |
75 | return raster; | 81 | return raster; |
@@ -15,9 +15,9 @@ | @@ -15,9 +15,9 @@ | ||
15 | */ | 15 | */ |
16 | 16 | ||
17 | import 'dart:async'; | 17 | import 'dart:async'; |
18 | -import 'dart:typed_data'; | ||
19 | import 'dart:ui' as ui; | 18 | import 'dart:ui' as ui; |
20 | 19 | ||
20 | +import 'package:flutter/foundation.dart'; | ||
21 | import 'package:flutter/material.dart'; | 21 | import 'package:flutter/material.dart'; |
22 | import 'package:flutter/rendering.dart'; | 22 | import 'package:flutter/rendering.dart'; |
23 | import 'package:flutter/widgets.dart'; | 23 | import 'package:flutter/widgets.dart'; |
@@ -126,6 +126,7 @@ class WidgetWrapper extends pw.ImageProvider { | @@ -126,6 +126,7 @@ class WidgetWrapper extends pw.ImageProvider { | ||
126 | /// ); | 126 | /// ); |
127 | /// ``` | 127 | /// ``` |
128 | static Future<WidgetWrapper> fromWidget({ | 128 | static Future<WidgetWrapper> fromWidget({ |
129 | + required BuildContext context, | ||
129 | required Widget widget, | 130 | required Widget widget, |
130 | required BoxConstraints constraints, | 131 | required BoxConstraints constraints, |
131 | double pixelRatio = 1.0, | 132 | double pixelRatio = 1.0, |
@@ -163,6 +164,9 @@ class WidgetWrapper extends pw.ImageProvider { | @@ -163,6 +164,9 @@ class WidgetWrapper extends pw.ImageProvider { | ||
163 | } | 164 | } |
164 | 165 | ||
165 | final repaintBoundary = RenderRepaintBoundary(); | 166 | final repaintBoundary = RenderRepaintBoundary(); |
167 | + // Flutter 3.9 | ||
168 | + // final view = View.of(context); | ||
169 | + final view = WidgetsBinding.instance.window; | ||
166 | 170 | ||
167 | final renderView = RenderView( | 171 | final renderView = RenderView( |
168 | child: RenderPositionedBox( | 172 | child: RenderPositionedBox( |
@@ -170,8 +174,8 @@ class WidgetWrapper extends pw.ImageProvider { | @@ -170,8 +174,8 @@ class WidgetWrapper extends pw.ImageProvider { | ||
170 | configuration: ViewConfiguration( | 174 | configuration: ViewConfiguration( |
171 | size: | 175 | size: |
172 | Size(computedConstraints.maxWidth, computedConstraints.maxHeight), | 176 | Size(computedConstraints.maxWidth, computedConstraints.maxHeight), |
173 | - devicePixelRatio: ui.window.devicePixelRatio), | ||
174 | - window: ui.window, | 177 | + devicePixelRatio: view.devicePixelRatio), |
178 | + window: view, | ||
175 | ); | 179 | ); |
176 | 180 | ||
177 | final pipelineOwner = PipelineOwner()..rootNode = renderView; | 181 | final pipelineOwner = PipelineOwner()..rootNode = renderView; |
@@ -258,6 +262,7 @@ class WidgetWraper extends WidgetWrapper { | @@ -258,6 +262,7 @@ class WidgetWraper extends WidgetWrapper { | ||
258 | /// Wrap a Flutter Widget to an ImageProvider. | 262 | /// Wrap a Flutter Widget to an ImageProvider. |
259 | @Deprecated('Use WidgetWrapper.fromWidget instead') | 263 | @Deprecated('Use WidgetWrapper.fromWidget instead') |
260 | static Future<WidgetWrapper> fromWidget({ | 264 | static Future<WidgetWrapper> fromWidget({ |
265 | + required BuildContext context, | ||
261 | required Widget widget, | 266 | required Widget widget, |
262 | required BoxConstraints constraints, | 267 | required BoxConstraints constraints, |
263 | double pixelRatio = 1.0, | 268 | double pixelRatio = 1.0, |
@@ -265,6 +270,7 @@ class WidgetWraper extends WidgetWrapper { | @@ -265,6 +270,7 @@ class WidgetWraper extends WidgetWrapper { | ||
265 | double? dpi, | 270 | double? dpi, |
266 | }) { | 271 | }) { |
267 | return WidgetWrapper.fromWidget( | 272 | return WidgetWrapper.fromWidget( |
273 | + context: context, | ||
268 | widget: widget, | 274 | widget: widget, |
269 | constraints: constraints, | 275 | constraints: constraints, |
270 | pixelRatio: pixelRatio, | 276 | pixelRatio: pixelRatio, |
-
Please register or login to post a comment