在开发过程中,我们很少会遇到预览pdf、word、excel、png、ppt等文件的功能,但是很巧的本人就遇到了,由于第一次使用这个功能,着实是让人挠头啊,最后终于得到解决。
其实实现预览功能很简单,Flutter的插件库就为我们提供了很好的插件
flutter_full_pdf_viewer: ^1.0.1
官网给的文件
import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_full_pdf_viewer/full_pdf_viewer_scaffold.dart';
import 'package:path_provider/path_provider.dart';
void main() {
runApp(MaterialApp(
title: 'Plugin example app',
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
String pathPDF = "";
@override
void initState() {
super.initState();
createFileOfPdfUrl().then((f)