Skip to content

All pdf file is not showing  #27

Description

@joshua750

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.
},
),
);
},
);
},
),
),
);
}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions