Created
April 3, 2020 12:51
-
-
Save VB10/c7fc6d3219adec2ab4ed2d04fdda9630 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:html' as html; | |
| import 'package:flutter/material.dart'; | |
| import 'dart:ui' as ui; | |
| import './pdf_web_view_view_model.dart'; | |
| class PdfWebViewView extends PdfWebViewViewModel { | |
| String samplePdf = "http://www.africau.edu/images/default/sample.pdf"; | |
| @override | |
| void initState() { | |
| super.initState(); | |
| registerView(pdfKey, "http://www.africau.edu/images/default/sample.pdf"); | |
| } | |
| Future<void> registerView(String key, String url) async { | |
| // ignore: undefined_prefixed_name | |
| await ui.platformViewRegistry.registerViewFactory( | |
| key, | |
| (int viewId) => html.IFrameElement() | |
| ..allowFullscreen = true | |
| ..src = '$url' | |
| ..style.border = 'none'); | |
| } | |
| String pdfKey = "key"; | |
| String pdfKey2 = "key2"; | |
| @override | |
| Widget build(BuildContext context) { | |
| // Replace this with your build function | |
| return Scaffold( | |
| appBar: AppBar( | |
| actions: <Widget>[ | |
| FloatingActionButton( | |
| onPressed: () async { | |
| pdfKey = 'veli'; | |
| await registerView('veli', | |
| "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"); | |
| setState(() {}); | |
| }, | |
| ) | |
| ], | |
| ), | |
| body: HtmlElementView(viewType: pdfKey), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment