Comments (4)
Full code:
import 'dart:io';
import 'package:file_manager/file_manager.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
requestStoragePermission();
}
Future<void> requestStoragePermission() async {
final PermissionStatus status = await Permission.storage.request();
if (status.isGranted) {
// Permission granted, perform your operations here
setState(() {
// You might update UI or trigger some actions upon permission grant
});
} else if (status.isDenied) {
// Permission denied
// You may want to display a dialog or message to the user explaining why you need this permission
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
themeMode: ThemeMode.dark,
theme: ThemeData(useMaterial3: true),
darkTheme: ThemeData(useMaterial3: true, brightness: Brightness.dark),
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
final FileManagerController controller = FileManagerController();
HomePage({super.key});
@override
Widget build(BuildContext context) {
return ControlBackButton(
controller: controller,
child: Scaffold(
appBar: AppBar(),
body: FileManager(
controller: controller,
builder: (context, snapshot) {
final List<FileSystemEntity> entities = snapshot;
return ListView.builder(
itemCount: entities.length,
itemBuilder: (context, index) {
return Card(
child: ListTile(
leading: FileManager.isFile(entities[index])
? Icon(Icons.feed_outlined)
: Icon(Icons.folder),
title: Text(FileManager.basename(entities[index])),
onTap: () {
if (FileManager.isDirectory(entities[index])) {
controller.openDirectory(entities[index]); // open directory
} else {
// Perform file-related tasks.
}
},
),
);
},
);
},
),
),
);
}
}
from flutter-permission-handler.
Which version of Android API that you used? I got this similar problem on API 28, and 31 but work fine on API 33, and 34 (Don't know why). Try to test your app on different Android API.
from flutter-permission-handler.
I'm using Android API 34. I tried using 33 as well but I get the same error
from flutter-permission-handler.
Dear @JagritParakh,
As per documentation:
/// Permission for accessing external storage.
///
/// Depending on the platform and version, the requirements are slightly
/// different:
///
/// **Android:**
/// - On Android 13 (API 33) and above, this permission is deprecated and
/// always returns `PermissionStatus.denied`. Instead use `Permission.photos`,
/// `Permission.video`, `Permission.audio` or
/// `Permission.manageExternalStorage`. For more information see our
/// [FAQ](https://pub.dev/packages/permission_handler#faq).
/// - Below Android 13 (API 33), the `READ_EXTERNAL_STORAGE` and
/// `WRITE_EXTERNAL_STORAGE` permissions are requested (depending on the
/// definitions in the AndroidManifest.xml) file.
///
/// **iOS:**
/// - Access to folders like `Documents` or `Downloads`. Implicitly granted.
static const storage = Permission._(15);
I'll close this issue for now. Feel free to reopen when new information becomes available.
Kind regards,
from flutter-permission-handler.
Related Issues (20)
- [Bug]: `permission_handler_apple` has an incorrect privacy manifest HOT 2
- Motion permission isGranted sometimes return FALSE on iOS even though the permission is granted by the user HOT 11
- [Question]: AppStore refuses app submission. HOT 3
- [Bug]: Debug App crashes when permission has changed
- [Question]: Add iOS privacy manifests HOT 4
- [Question]: Why AppLifeCycleListener method called repeatedly HOT 1
- [Enhancement proposal]: Add wasm support
- [Question]:I'm facing Permission.PermentlyDenied issue even after requesting or manually giving the permission to app i'm not able to access files in external storage in android 13 whereas I don't face thise issue in android 11 or below HOT 1
- [Question]:I'm facing Permission.PermentlyDenied issue even after requesting or manually giving the permission to app i'm not able to access files in external storage in android 13 whereas I don't face thise issue in android 11 or below HOT 1
- [Bug]: CalendarFullAccess status is always denied in iOS 17+ HOT 5
- [Feature request]: manageExternalStorage in iOS HOT 1
- [Bug]: Firefox: TypeError: 'camera' (value of 'name' member of PermissionDescriptor) is not a valid value for enumeration PermissionName HOT 2
- [Bug]: Gets Permission Granted Status for Limited Permission HOT 2
- [Bug]: Turning on and turning off external storage causes app crash. HOT 3
- [Bug]: Permission.camera.request() throwing permission denied even if I have granted. HOT 9
- [Question]: Failed to initialize decoder: c2.unisoc.avc.decoder HOT 1
- [Question]: ITMS-91053: Missing API declaration HOT 1
- [Bug]: Camera status is always denied in iOS 17 HOT 8
- Permission.backgroundRefresh.status not available anymore HOT 1
- /usr/include/c++/11/cmath:45:15: fatal error: math.h: No such file or directory *** 45 | #include_next <math.h> *** | ^~~~~~~~ *** compilation terminated. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter-permission-handler.