Bonjour, je crée un fichier PDF, puis je stocke son chemin local vers des préférences partagées, mais lorsque je recette le chemin du fichier, l'impression est une parfaite dans la console mais que vous ne pouvez pas le charger comme FilePath.
Sauvegarde P> récupérer et stocker dans maintenant lorsque je l'appelle directement à son fonctionnement variable cela ne fait rien. p>
3 Réponses :
// save
var addressp = '$pdffilename$time';
sharedPrefs.setString('addressp', addressp);
// read
addressp = sharedPrefs.getString('addressp');
PdfViewer (
filePath: "$documentPath/$addressp",
),
@override
void initState() {
getValues();
super.initState();
}
String completePath;
var ValShrdPr;
String documentPath;
getValues() async {
Directory documentDirectory = await getApplicationDocumentsDirectory();
documentPath = await documentDirectory.path;
SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
ValShrdPr = await sharedPrefs.getString('addressp');
completePath = '$documentPath/$ValShrdPr.pdf';
}
And getting this errorSyncing files to device Android SDK built for x86...
D/EGL_emulation(18737): eglMakeCurrent: 0xe1ec3ec0: ver 3 1 (tinfo 0xe1ec8c20)
Restarted application in 4,817ms.
D/com.shockwave.pdfium.PdfiumCore(18737): Starting PdfiumAndroid 1.9.0
D/EGL_emulation(18737): eglMakeCurrent: 0xe1ec3ec0: ver 3 1 (tinfo 0xe1ec8c20)
E/PDFView (18737): load pdf error
E/PDFView (18737): java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
E/PDFView (18737): at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:315)
E/PDFView (18737): at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:220)
E/PDFView (18737): at com.github.barteksc.pdfviewer.source.FileSource.createDocument(FileSource.java:37)
E/PDFView (18737): at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:53)
E/PDFView (18737): at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:27)
E/PDFView (18737): at android.os.AsyncTask$3.call(AsyncTask.java:378)
E/PDFView (18737): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/PDFView (18737): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/PDFView (18737): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/PDFView (18737): at java.lang.Thread.run(Thread.java:919)
Monsieur Merci pour un soutien aimable, j'ai trouvé le problème réel que le code PDFViews (FilePath: adressep) a été appelé d'abord qui était null et après que le code soit exécuté et que l'État n'était pas mis à jour. P>
maintenant p>
Je reçois la première valeur dans la page précédente, puis la transmettez comme variable et sa bien a fonctionné. P>
Ne sauvegardez pas le chemin complet, sauvegardez le chemin relatif, comme
/app_flutter/inven15.pdf code> ou/Inven1598561218015.pdf code> dans votre cas.Ajoutez votre chemin racine de l'application lors de l'utilisation.
Monsieur peut me donner un exemple de code comme je le nouveau. Merci.
Pouvez-vous fournir un code plus détaillé alors?
Github.com/divid0n1/inventoryCheck/blob/Master/LIB/ UI / ...