"view document in browser flutter web" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "view document in browser flutter web" answered properly. Developers are finding an appropriate answer about view document in browser flutter web related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like view document in browser flutter web. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on view document in browser flutter web.
view document in browser flutter web
import 'package:flutter/material.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:universal_html/html.dart' as html;
class PdfDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
final pdf = pw.Document();
pdf.addPage(pw.Page(
pageFormat: PdfPageFormat.a4,
build: (pw.Context context) {
return pw.Center(
child: pw.Text("Hello World"),
);
}));
final bytes = pdf.save();
final blob = html.Blob([bytes], 'application/pdf');
return Scaffold(
appBar: AppBar(),
body: Center(
child: Column(
children: <Widget>[
RaisedButton(
child: Text("Open"),
onPressed: () {
final url = html.Url.createObjectUrlFromBlob(blob);
html.window.open(url, "_blank");
html.Url.revokeObjectUrl(url);
},
),
RaisedButton(
child: Text("Download"),
onPressed: () {
final url = html.Url.createObjectUrlFromBlob(blob);
final anchor =
html.document.createElement('a') as html.AnchorElement
..href = url
..style.display = 'none'
..download = 'some_name.pdf';
html.document.body.children.add(anchor);
anchor.click();
html.document.body.children.remove(anchor);
html.Url.revokeObjectUrl(url);
},
),
],
mainAxisAlignment: MainAxisAlignment.center,
),
),
);
}
}
Source: stackoverflow.com
All those coders who are working on the Whatever based application and are stuck on view document in browser flutter web can get a collection of related answers to their query. Programmers need to enter their query on view document in browser flutter web related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about view document in browser flutter web for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of view document in browser flutter web while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "view document in browser flutter web". Visit this developer's friendly online web community, CodeProZone, and get your queries like view document in browser flutter web resolved professionally and stay updated to the latest Whatever updates.