In a Flutter project I create a pdf document. I can save the document in the path of the app. But the user has no access to it. Alternatively, how can I save the file to another folder where the user sees it?
import 'package:path_provider/path_provider.dart';
Future<void> savePdfDocument() async {
final PdfCreater generatedPdf = PdfCreater(document);
final List<int> generatedPdfDocument = generatedPdf.buildPdf();
final String dir = (await getApplicationDocumentsDirectory()).path;
final String path = '$dir/example.pdf';
final File file = File(path);
file.writeAsBytesSync(generatedPdfDocument);
}
android/data/data/your_package_name/
folder, if you want to save the file in root directory, you can simply change the path, but make sure you have access to storage permission in Android. – BeginninggetApplicationDocumentsDirectory()
isnt accessible to the user. The name can be misleading, its not the documents folder that you see in your phone's File menu – Gussetdocument
folder ins't the one which is at the root of your SD card directory. I thought it's theandroid/data/package/files
one but turned out it'sdata/data/package/app_flutter/
which indeed ins't accessible to the user. – Beginning