Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update widget_wrapper.dart #1635

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions printing/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,20 @@ dependencies:
image: ^4.0.02
js: ">=0.6.3 <1.0.0"
meta: ">=1.3.0 <2.0.0"
pdf: ^3.10.0
pdf_widget_wrapper: '>=1.0.0 <2.0.0'
# old pdf pacakge was here and replaced with mine
pdf:
git:
url: https://github.com/Akinsola1/dart_pdf_forked
ref: master
path: ./pdf

# also replacing this with the one i forked
# pdf_widget_wrapper: '>=1.0.0 <2.0.0'
pdf_widget_wrapper:
git:
url: https://github.com/Akinsola1/dart_pdf_forked
ref: master
path: ./widget_wrapper
plugin_platform_interface: ^2.1.0

dev_dependencies:
Expand Down
58 changes: 54 additions & 4 deletions widget_wrapper/lib/src/widget_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ class WidgetWrapper extends pw.ImageProvider {
child: RenderPositionedBox(
alignment: Alignment.center, child: repaintBoundary),
configuration: ViewConfiguration(
size: Size(
computedConstraints.maxWidth,
computedConstraints.maxHeight,
),
physicalConstraints: BoxConstraints(maxWidth:computedConstraints.maxWidth, maxHeight: computedConstraints.maxHeight ),
// size:
// Size(computedConstraints.maxWidth, computedConstraints.maxHeight),
devicePixelRatio: view.devicePixelRatio),
view: view,
);
Expand Down Expand Up @@ -228,3 +227,54 @@ class WidgetWrapper extends pw.ImageProvider {
);
}
}

/// ImageProvider that draws a Flutter Widget on a PDF document
@Deprecated('Use WidgetWrapper instead')
class WidgetWraper extends WidgetWrapper {
WidgetWraper._(
Uint8List bytes,
int width,
int height,
PdfImageOrientation orientation,
double? dpi,
) : super._(bytes, width, height, orientation, dpi);

/// Wrap a Flutter Widget identified by a GlobalKey to an ImageProvider.
@Deprecated('Use WidgetWrapper.fromKey instead')
static Future<WidgetWrapper> fromKey({
required GlobalKey key,
int? width,
int? height,
double pixelRatio = 1.0,
PdfImageOrientation? orientation,
double? dpi,
}) {
return WidgetWrapper.fromKey(
key: key,
width: width,
pixelRatio: pixelRatio,
orientation: orientation,
dpi: dpi,
);
}

/// 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,
PdfImageOrientation? orientation,
double? dpi,
}) {
return WidgetWrapper.fromWidget(
context: context,
widget: widget,
constraints: constraints,
pixelRatio: pixelRatio,
orientation: orientation,
dpi: dpi,
);
}
}
7 changes: 6 additions & 1 deletion widget_wrapper/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ environment:
dependencies:
flutter:
sdk: flutter
pdf: ^3.10.0
# pdf: ^3.10.0
pdf:
git:
url: https://github.com/Akinsola1/dart_pdf_forked
ref: master
path: ./pdf

dependency_overrides:
pdf:
Expand Down