In my AppBar menu I tried to put a button with this function (for change the screen):
onPressed: (){
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Read_Pdf()),
);
}
But always appears "... => Read_Pdf())," with error cause "2 positional argument(s) expected, but 0 found. Try adding the missing arguments."
This is the content of the file.dart which contains the Read_Pdf Class:
import 'dart:io';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter_full_pdf_viewer/full_pdf_viewer_scaffold.dart';
const String _documentPath = 'PDFs/manual_demo.pdf';
// ignore: camel_case_types
class Read_Pdf extends StatelessWidget {
final BuildContext context;
String pdfPath;
Read_Pdf(this.context, this.pdfPath);
Future<String> prepareTestPdf() async {
final ByteData bytes = await DefaultAssetBundle.of(context).load(_documentPath);
final Uint8List list = bytes.buffer.asUint8List();
final tempDir = await getTemporaryDirectory();
final tempDocumentPath = '${tempDir.path}/$_documentPath';
final file = await File(tempDocumentPath).create(recursive: true);
file.writeAsBytesSync(list);
return tempDocumentPath;
}
@override
Widget build(BuildContext context) {
return PDFViewerScaffold(
appBar: AppBar(
title: Text("Document"),
),
path: pdfPath);
}
}
I know that there is a conflict with the pdfPath variable, but I don´t know how to solve it.