Skip to content

Commit

Permalink
update pdf view can use HybridComposition or not, fix issue pdf worki…
Browse files Browse the repository at this point in the history
…ng incorrect on samsung android 14.
  • Loading branch information
LocLt-Mobile committed Dec 25, 2023
1 parent 15f8fef commit 422d348
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/flutter_pdfview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PDFView extends StatefulWidget {
this.defaultPage = 0,
this.fitPolicy = FitPolicy.WIDTH,
this.preventLinkNavigation = false,
this.useHybridComposition = false,
})
: assert(filePath != null || pdfData != null),
super(key: key);
Expand Down Expand Up @@ -80,6 +81,7 @@ class PDFView extends StatefulWidget {
final FitPolicy fitPolicy;
final bool fitEachPage;
final bool preventLinkNavigation;
final bool useHybridComposition;
}

class _PDFViewState extends State<PDFView> {
Expand All @@ -101,6 +103,20 @@ class _PDFViewState extends State<PDFView> {
);
},
onCreatePlatformView: (PlatformViewCreationParams params) {
if (widget.useHybridComposition) {
return PlatformViewsService.initExpensiveAndroidView(
id: params.id,
viewType: 'plugins.endigo.io/pdfview',
layoutDirection: TextDirection.rtl,
creationParams: _CreationParams.fromWidget(widget).toMap(),
creationParamsCodec: const StandardMessageCodec(),
)
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..addOnPlatformViewCreatedListener((int id) {
_onPlatformViewCreated(id);
})
..create();
}
return PlatformViewsService.initSurfaceAndroidView(
id: params.id,
viewType: 'plugins.endigo.io/pdfview',
Expand Down

0 comments on commit 422d348

Please sign in to comment.