I use flutter_pdfview to generate thumbnail image widget of online pdf file, by the following code, and got error: The method 'render' isn't defined for the type PDFViewController.
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_pdfview/flutter_pdfview.dart';
class PdfThumbnail extends StatefulWidget {
final String path;
final double height;
final double width;
PdfThumbnail({required this.path, required this.height, required this.width});
@override
_PdfThumbnailState createState() => _PdfThumbnailState();
}
class _PdfThumbnailState extends State<PdfThumbnail> {
late PDFViewController pdfViewController;
Uint8List? imageBytes;
@override
void initState() {
super.initState();
_renderPdf();
}
void _renderPdf() async {
final data = await pdfViewController.render( //here is the error.
page: 1,
x: 0.0,
y: 0.0,
width: widget.width,
height: widget.height,
);
setState(() {
imageBytes = data!;
});
}
@override
Widget build(BuildContext context) {
return imageBytes != null
? Image.memory(
imageBytes!,
width: widget.width,
height: widget.height,
fit: BoxFit.cover,
)
: Container();
}
}
I guessed that the method has been changed in the upgraded version, so I read the documentation of PDFViewController class but could not find the similar method.