flutter_file_manager

A set of utilities, that help to manage the files & directories in Android system.

You are in your way to create File Manager app or a Gallery App.

Usage

To use this package, add these
dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter
  path: 1.6.2
  path_provider: 0.5.0+1
  flutter_file_manager: ^0.1.1

And, add read / write permissions in your
android/app/src/main/AndroidManifest.xml

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

Don't forget to grant Storage permissions to your app, manually or by this plugin simple_permissions

// framework
import 'package:flutter/material.dart';

// packages
import 'package:flutter_file_manager/flutter_file_manager.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as p;

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("Flutter File Manager Demo"),
          ),
          body: FutureBuilder(
            future: _files(), // a previously-obtained Future<String> or null
            builder: (BuildContext context, AsyncSnapshot snapshot) {
              switch (snapshot.connectionState) {
                case ConnectionState.none:
                  return Text('Press button to start.');
                case ConnectionState.active:
                case ConnectionState.waiting:
                  return Text('Awaiting result...');
                case ConnectionState.done:
                  if (snapshot.hasError)
                    return Text('Error: ${snapshot.error}');
                  return snapshot.data != null
                      ? ListView.builder(
                          itemCount: snapshot.data.length,
                          itemBuilder: (context, index) => Card(
                                  child: ListTile(
                                title: Text(snapshot.data[index].absolute.path),
                                subtitle: Text(
                                    "Extension: ${p.extension(snapshot.data[index].absolute.path).replaceFirst('.', '')}"), // getting extension
                              )))
                      : Center(
                          child: Text("Nothing!"),
                        );
              }
              return null; // unreachable
            },
          )),
    );
  }

  _files() async {
    var root = await getExternalStorageDirectory();
    var fm = FileManager(root: root);
    var files = await fm.filesTree(excludedPaths: ["/storage/emulated/0/Android"]);
    return files;
  }
}

Example

Features

  • file details
  • search files or directories: supports regular expressions
  • recent created files: you can exclude a list of directories from the tree
  • directories only tree: you can exclude a list of directories from the tree
  • files only tree: you can exclude a list of directories from the tree
  • files list from specific point
  • delete files
  • delete directory
  • temp file
  • Sorting file by: type, size, date, ..

GitHub

https://github.com/Eagle6789/flutter_file_manager