file_access_settings_return

A lightweight Flutter plugin that helps Android apps return to the foreground after users complete file access authorization in system settings.

Features

  • Check file storage permission status
  • Automatically bring app back to foreground after permission is granted in system settings
  • Support for Android 11+ (MANAGE_EXTERNAL_STORAGE) and Android 10 and below (READ/WRITE_EXTERNAL_STORAGE)

Platform Support

Android iOS

Installation

Add this to your pubspec.yaml:

dependencies:
  file_access_settings_return: ^1.0.0

Android Setup

Add the following permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

Usage

import 'package:file_access_settings_return/file_access_settings_return.dart';

final plugin = FileAccessSettingsReturn();

// Check if permission is granted
bool hasPermission = await plugin.hasStoragePermission();

// Before opening system settings, call this to start polling
await plugin.notifyEnterPermissionPage();

// Open system settings and request permission (use permission_handler or similar)
// ...

// After returning from settings, cancel polling
await plugin.cancelPermissionPolling();

API

Method Description
hasStoragePermission() Returns true if file access permission is granted
notifyEnterPermissionPage() Call before opening system settings. Starts polling and auto-returns app to foreground when permission is granted
cancelPermissionPolling() Stops the permission polling. Call when user returns or cancels

License

MIT License