|
| 1 | +library syncfusion_pdfviewer_platform_interface; |
| 2 | + |
| 3 | +import 'dart:async'; |
| 4 | +import 'dart:typed_data'; |
| 5 | +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; |
| 6 | +import 'package:syncfusion_pdfviewer_platform_interface/src/method_channel_pdfviewer.dart'; |
| 7 | + |
| 8 | +/// The interface that implementations of syncfusion_flutter_pdfviewer must implement. |
| 9 | +/// |
| 10 | +/// Platform implementations should extend this class rather than implement it as `syncfusion_flutter_pdfviewer` |
| 11 | +/// does not consider newly added methods to be breaking changes. Extending this class |
| 12 | +/// (using `extends`) ensures that the subclass will get the default implementation, while |
| 13 | +/// platform implementations that `implements` this interface will be broken by newly added |
| 14 | +/// [PdfViewerPlatform] methods |
| 15 | +abstract class PdfViewerPlatform extends PlatformInterface { |
| 16 | + /// Constructs a PdfViewerPlatform. |
| 17 | + PdfViewerPlatform() : super(token: _token); |
| 18 | + static PdfViewerPlatform _instance = MethodChannelPdfViewer(); |
| 19 | + |
| 20 | + static final Object _token = Object(); |
| 21 | + |
| 22 | + /// The default instance of [PdfViewerPlatform] to use. |
| 23 | + /// |
| 24 | + /// Defaults to [MethodChannelPdfViewer] |
| 25 | + static PdfViewerPlatform get instance => _instance; |
| 26 | + |
| 27 | + /// Platform-specific plugins should set this with their own platform-specific |
| 28 | + /// class that extends [PdfViewerPlatform] when they register themselves. |
| 29 | + static set instance(PdfViewerPlatform instance) { |
| 30 | + PlatformInterface.verifyToken(instance, _token); |
| 31 | + _instance = instance; |
| 32 | + } |
| 33 | + |
| 34 | + /// Initializes the PDF renderer instance in respective platform by loading the PDF from the specified path. |
| 35 | + /// |
| 36 | + /// If success, returns page count else returns error message from respective platform |
| 37 | + Future<String?> initializePdfRenderer( |
| 38 | + Uint8List documentBytes, String documentID) async { |
| 39 | + throw UnimplementedError( |
| 40 | + 'initializePdfRenderer() has not been implemented.'); |
| 41 | + } |
| 42 | + |
| 43 | + /// Gets the height of all pages in the document. |
| 44 | + Future<List?> getPagesHeight(String documentID) async { |
| 45 | + throw UnimplementedError('getPagesHeight() has not been implemented.'); |
| 46 | + } |
| 47 | + |
| 48 | + /// Gets the width of all pages in the document. |
| 49 | + Future<List?> getPagesWidth(String documentID) async { |
| 50 | + throw UnimplementedError('getPagesWidth() has not been implemented.'); |
| 51 | + } |
| 52 | + |
| 53 | + /// Gets the image's bytes information of the specified page. |
| 54 | + Future<Uint8List?> getImage( |
| 55 | + int pageNumber, double scale, String documentID) async { |
| 56 | + throw UnimplementedError('getImage() has not been implemented.'); |
| 57 | + } |
| 58 | + |
| 59 | + /// Gets the image's bytes information of the specified portion of the page. |
| 60 | + Future<Uint8List?> getTileImage(int pageNumber, double scale, double x, |
| 61 | + double y, double width, double height, String documentID) async { |
| 62 | + throw UnimplementedError('getTileImage() has not been implemented.'); |
| 63 | + } |
| 64 | + |
| 65 | + /// Closes the PDF document. |
| 66 | + Future<void> closeDocument(String documentID) async { |
| 67 | + throw UnimplementedError('closeDocument() has not been implemented.'); |
| 68 | + } |
| 69 | +} |
0 commit comments