David PHAM-VAN

Fix more Flutter 3.9 deprecations

... ... @@ -67,8 +67,7 @@ class PdfPreviewData extends ChangeNotifier {
PdfPageFormat get actualPageFormat => _onComputeActualPageFormat();
String get localPageFormat {
final wbi = WidgetsBinding.instance;
final locale = wbi.window.locale;
final locale = WidgetsBinding.instance.platformDispatcher.locale;
final cc = locale.countryCode ?? 'US';
if (cc == 'US' || cc == 'CA' || cc == 'MX') {
... ...
... ... @@ -70,6 +70,12 @@ class PdfRasterImage extends ImageProvider<PdfRaster> {
return OneFrameImageStreamCompleter(_loadAsync());
}
// Flutter 3.9
// @override
// ImageStreamCompleter loadImage(PdfRaster key, ImageDecoderCallback decode) {
// return OneFrameImageStreamCompleter(_loadAsync());
// }
@override
Future<PdfRaster> obtainKey(ImageConfiguration configuration) async {
return raster;
... ...
... ... @@ -15,9 +15,9 @@
*/
import 'dart:async';
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
... ... @@ -126,6 +126,7 @@ class WidgetWrapper extends pw.ImageProvider {
/// );
/// ```
static Future<WidgetWrapper> fromWidget({
required BuildContext context,
required Widget widget,
required BoxConstraints constraints,
double pixelRatio = 1.0,
... ... @@ -163,6 +164,9 @@ class WidgetWrapper extends pw.ImageProvider {
}
final repaintBoundary = RenderRepaintBoundary();
// Flutter 3.9
// final view = View.of(context);
final view = WidgetsBinding.instance.window;
final renderView = RenderView(
child: RenderPositionedBox(
... ... @@ -170,8 +174,8 @@ class WidgetWrapper extends pw.ImageProvider {
configuration: ViewConfiguration(
size:
Size(computedConstraints.maxWidth, computedConstraints.maxHeight),
devicePixelRatio: ui.window.devicePixelRatio),
window: ui.window,
devicePixelRatio: view.devicePixelRatio),
window: view,
);
final pipelineOwner = PipelineOwner()..rootNode = renderView;
... ... @@ -258,6 +262,7 @@ class WidgetWraper extends WidgetWrapper {
/// Wrap a Flutter Widget to an ImageProvider.
@Deprecated('Use WidgetWrapper.fromWidget instead')
static Future<WidgetWrapper> fromWidget({
required BuildContext context,
required Widget widget,
required BoxConstraints constraints,
double pixelRatio = 1.0,
... ... @@ -265,6 +270,7 @@ class WidgetWraper extends WidgetWrapper {
double? dpi,
}) {
return WidgetWrapper.fromWidget(
context: context,
widget: widget,
constraints: constraints,
pixelRatio: pixelRatio,
... ...