Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All pdf file is not showing #27

Open
joshua750 opened this issue Jul 5, 2023 · 0 comments
Open

All pdf file is not showing #27

joshua750 opened this issue Jul 5, 2023 · 0 comments

Comments

@joshua750
Copy link

its not showing all pdf file from phone storages
here is my code it just showing me only two file form this location
/storage/emulated/0 while i have lot pdf file please tell me what issue in this code or plugin?

import 'dart:io';
import 'package:file_manager/file_manager.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart' as path;
import 'package:permission_handler/permission_handler.dart';

class Pdflist extends StatefulWidget {
const Pdflist({Key? key}) : super(key: key);

@OverRide
State createState() => _PdflistState();
}

class _PdflistState extends State {
final FileManagerController controller = FileManagerController();

@OverRide
void initState() {
super.initState();
checkPermissionStatus();
}

Future checkPermissionStatus() async {
final status = await Permission.storage.status;
setState(() {
if (status.isGranted) {
print('PERMISSION Access');
} else if (status.isDenied) {
requestPermission();
}
});
}

Future requestPermission() async {
final status = await Permission.storage.request();
setState(() {});
}

Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('All PDFs'),
),
body: Container(
child: FileManager(
controller: controller,
builder: (context, snapshot) {
final List entities = snapshot;
final List pdfFiles = entities
.where((entity) =>
FileManager.isFile(entity) &&
path.extension(entity.path).toLowerCase() == '.pdf')
.toList();
return ListView.builder(
itemCount: pdfFiles.length,
itemBuilder: (context, index) {
return Card(
child: ListTile(
leading: Icon(Icons.file_present),
title: Text(FileManager.basename(pdfFiles[index])),
onTap: () {
// Perform file-related tasks.
},
),
);
},
);
},
),
),
);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant